1 |
– |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Holodeck display process. |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include <string.h> |
9 |
+ |
#include <ctype.h> |
10 |
+ |
|
11 |
+ |
#include "rterror.h" |
12 |
|
#include "rholo.h" |
13 |
|
#include "rhdisp.h" |
14 |
|
#include "rhdriver.h" |
15 |
|
#include "selcall.h" |
15 |
– |
#include <ctype.h> |
16 |
|
|
17 |
|
#ifndef VIEWHISTLEN |
18 |
|
#define VIEWHISTLEN 4 /* number of remembered views */ |
19 |
|
#endif |
20 |
|
|
21 |
+ |
#ifndef FSIZDEF |
22 |
+ |
#define FSIZDEF 0.125 /* default focus frame size */ |
23 |
+ |
#endif |
24 |
+ |
|
25 |
+ |
#if defined(freebsd) |
26 |
+ |
#define fbufcnt(f) ((f)->_r) |
27 |
+ |
#elif defined(__GNUC__) |
28 |
+ |
#define fbufcnt(f) ((f)->_IO_read_end - (f)->_IO_read_ptr) |
29 |
+ |
#else |
30 |
+ |
#define fbufcnt(f) ((f)->_cnt) |
31 |
+ |
#endif |
32 |
+ |
|
33 |
|
HOLO *hdlist[HDMAX+1]; /* global holodeck list */ |
34 |
|
|
35 |
+ |
char *hdgfn[HDMAX]; /* holodeck section geometry list */ |
36 |
+ |
char *hdpfn[HDMAX]; /* section portal list */ |
37 |
+ |
|
38 |
|
char cmdlist[DC_NCMDS][8] = DC_INIT; |
39 |
|
|
40 |
|
int imm_mode = 0; /* bundles are being delivered immediately */ |
48 |
|
FILE *sstdin, *sstdout; /* server's standard input and output */ |
49 |
|
|
50 |
|
#ifdef DEBUG |
36 |
– |
#include <sys/types.h> |
51 |
|
extern time_t time(); |
52 |
|
static time_t tmodesw; |
53 |
|
static time_t timm, tadd; |
58 |
|
#define RDY_DEV 02 |
59 |
|
#define RDY_SIN 04 |
60 |
|
|
61 |
+ |
static int disp_wait(void); |
62 |
+ |
static void add_holo(HDGRID *hdg, char *gfn, char *pfn); |
63 |
+ |
static void disp_bundle(PACKHEAD *p); |
64 |
+ |
static void new_view(VIEW *v); |
65 |
+ |
static void set_focus(char *args); |
66 |
+ |
static int usr_input(void); |
67 |
+ |
static void printview(void); |
68 |
|
|
69 |
< |
main(argc, argv) |
70 |
< |
int argc; |
71 |
< |
char *argv[]; |
69 |
> |
|
70 |
> |
int |
71 |
> |
main( |
72 |
> |
int argc, |
73 |
> |
char *argv[] |
74 |
> |
) |
75 |
|
{ |
52 |
– |
extern int eputs(); |
76 |
|
int rdy, inp, res = 0, pause = 0; |
77 |
|
|
78 |
|
progname = argv[0]; |
107 |
|
inp = dev_input(); |
108 |
|
if (inp & DFL(DC_SETVIEW)) |
109 |
|
new_view(&odev.v); |
110 |
+ |
else if (inp & DFL(DC_LASTVIEW)) |
111 |
+ |
new_view(NULL); |
112 |
+ |
if (inp & DFL(DC_REDRAW)) |
113 |
+ |
imm_mode = beam_sync(1) > 0; |
114 |
|
if (inp & DFL(DC_GETVIEW)) |
115 |
|
printview(); |
116 |
< |
if (inp & DFL(DC_LASTVIEW)) |
117 |
< |
new_view(NULL); |
116 |
> |
if (inp & DFL(DC_FOCUS)) |
117 |
> |
set_focus(odev_args); |
118 |
|
if (inp & DFL(DC_KILL)) { |
119 |
|
serv_request(DR_KILL, 0, NULL); |
120 |
|
pause = 0; |
131 |
|
} |
132 |
|
if (inp & DFL(DC_PAUSE)) |
133 |
|
pause = 1; |
107 |
– |
if (inp & DFL(DC_REDRAW)) |
108 |
– |
imm_mode = beam_sync(1) > 0; |
134 |
|
if (inp & DFL(DC_QUIT)) |
135 |
|
serv_request(DR_SHUTDOWN, 0, NULL); |
136 |
|
} |
160 |
|
#endif |
161 |
|
/* all done */ |
162 |
|
quit(0); |
163 |
+ |
return 0; /* pro forma return */ |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
< |
int |
168 |
< |
disp_wait() /* wait for more input */ |
167 |
> |
static int |
168 |
> |
disp_wait(void) /* wait for more input */ |
169 |
|
{ |
170 |
|
fd_set readset, errset; |
171 |
|
int flgs; |
172 |
|
int n; |
147 |
– |
register int i; |
173 |
|
/* see if we can avoid select call */ |
174 |
+ |
if (hdlist[0] == NULL) |
175 |
+ |
return(RDY_SRV); /* initialize first */ |
176 |
|
flgs = 0; /* flag what's ready already */ |
177 |
< |
if (imm_mode || stdin->_cnt > 0) |
177 |
> |
if (imm_mode || fbufcnt(stdin) > 0) |
178 |
|
flgs |= RDY_SRV; |
179 |
< |
if (sstdin != NULL && sstdin->_cnt > 0) |
179 |
> |
if (sstdin != NULL && fbufcnt(sstdin) > 0) |
180 |
|
flgs |= RDY_SIN; |
181 |
|
if (odev.inpready) |
182 |
|
flgs |= RDY_DEV; |
214 |
|
} |
215 |
|
|
216 |
|
|
217 |
< |
add_holo(hdg) /* register a new holodeck section */ |
218 |
< |
HDGRID *hdg; |
217 |
> |
static void |
218 |
> |
add_holo( /* a new holodeck section */ |
219 |
> |
HDGRID *hdg, |
220 |
> |
char *gfn, |
221 |
> |
char *pfn |
222 |
> |
) |
223 |
|
{ |
224 |
|
VIEW nv; |
225 |
|
double d; |
226 |
< |
register int hd; |
226 |
> |
int hd; |
227 |
|
|
228 |
|
for (hd = 0; hd < HDMAX && hdlist[hd] != NULL; hd++) |
229 |
|
; |
232 |
|
hdlist[hd] = (HOLO *)malloc(sizeof(HOLO)); |
233 |
|
if (hdlist[hd] == NULL) |
234 |
|
error(SYSTEM, "out of memory in add_holo"); |
235 |
< |
bcopy((char *)hdg, (char *)hdlist[hd], sizeof(HDGRID)); |
235 |
> |
memcpy((void *)hdlist[hd], (void *)hdg, sizeof(HDGRID)); |
236 |
|
hdcompgrid(hdlist[hd]); |
237 |
+ |
hdgfn[hd] = savestr(gfn); |
238 |
+ |
hdpfn[hd] = pfn && *pfn ? savestr(pfn) : (char *)NULL; |
239 |
|
if (hd) |
240 |
|
return; |
241 |
|
/* set initial viewpoint */ |
242 |
< |
copystruct(&nv, &odev.v); |
242 |
> |
nv = odev.v; |
243 |
|
VSUM(nv.vp, hdlist[0]->orig, hdlist[0]->xv[0], 0.5); |
244 |
|
VSUM(nv.vp, nv.vp, hdlist[0]->xv[1], 0.5); |
245 |
|
VSUM(nv.vp, nv.vp, hdlist[0]->xv[2], 0.5); |
255 |
|
} |
256 |
|
|
257 |
|
|
258 |
< |
disp_bundle(p) /* display a ray bundle */ |
259 |
< |
register PACKHEAD *p; |
258 |
> |
static void |
259 |
> |
disp_bundle( /* display a ray bundle */ |
260 |
> |
PACKHEAD *p |
261 |
> |
) |
262 |
|
{ |
263 |
|
GCOORD gc[2]; |
264 |
|
FVECT ro, rd, wp; |
265 |
|
double d; |
266 |
< |
register int i; |
266 |
> |
int i; |
267 |
|
/* get beam coordinates */ |
268 |
< |
if (p->hd < 0 | p->hd >= HDMAX || hdlist[p->hd] == NULL) |
268 |
> |
if ((p->hd < 0) | (p->hd >= HDMAX) || hdlist[p->hd] == NULL) |
269 |
|
error(INTERNAL, "bad holodeck number in disp_bundle"); |
270 |
|
if (!hdbcoord(gc, hdlist[p->hd], p->bi)) |
271 |
|
error(INTERNAL, "bad beam index in disp_bundle"); |
286 |
|
} |
287 |
|
|
288 |
|
|
289 |
< |
new_view(v) /* change view parameters */ |
290 |
< |
register VIEW *v; |
289 |
> |
static void |
290 |
> |
new_view( /* change view parameters */ |
291 |
> |
VIEW *v |
292 |
> |
) |
293 |
|
{ |
294 |
|
static VIEW viewhist[VIEWHISTLEN]; |
295 |
|
static unsigned nhist; |
296 |
|
VIEW *dv; |
297 |
|
int i, res[2]; |
298 |
+ |
int16 *slist; |
299 |
|
char *err; |
300 |
|
/* restore previous view? */ |
301 |
|
if (v == NULL) { |
311 |
|
error(COMMAND, err); |
312 |
|
return; |
313 |
|
} |
314 |
+ |
if (!dev_view(v)) /* notify display driver */ |
315 |
+ |
goto again; |
316 |
|
if (v->type == VT_PAR) { |
317 |
|
error(COMMAND, "cannot handle parallel views"); |
318 |
|
return; |
319 |
|
} |
320 |
< |
if (!dev_view(v)) /* notify display driver */ |
321 |
< |
goto again; |
322 |
< |
dev_flush(); /* update screen */ |
283 |
< |
beam_init(0); /* compute new beam set */ |
284 |
< |
for (i = 0; (dv = dev_auxview(i, res)) != NULL; i++) |
285 |
< |
if (!beam_view(dv, res[0], res[1])) { |
320 |
> |
beam_init(odev.firstuse); /* compute new beam set */ |
321 |
> |
for (i = 0; (dv = dev_auxview(i, res)) != NULL; i++) { |
322 |
> |
if ((slist = beam_view(dv, res[0], res[1])) == NULL) { |
323 |
|
if (!nhist) { |
324 |
|
error(COMMAND, "invalid starting view"); |
325 |
|
return; |
326 |
|
} |
327 |
< |
copystruct(v, viewhist + ((nhist-1)%VIEWHISTLEN)); |
328 |
< |
goto again; |
329 |
< |
} |
327 |
> |
*v = *(viewhist + ((nhist-1)%VIEWHISTLEN)); |
328 |
> |
goto again; /* XXX overloading dev_section()? */ |
329 |
> |
} |
330 |
> |
DCHECK(*slist < 0, WARNING, "no visible sections in new_view"); |
331 |
> |
for ( ; *slist >= 0; slist++) |
332 |
> |
dev_section(hdgfn[*slist], hdpfn[*slist]); |
333 |
> |
} |
334 |
> |
dev_section(NULL,NULL); /* end section list */ |
335 |
> |
dev_flush(); /* update display */ |
336 |
|
/* update server */ |
337 |
< |
imm_mode = beam_sync(0) > 0; |
337 |
> |
imm_mode = beam_sync(odev.firstuse) > 0; |
338 |
|
/* record new view */ |
339 |
|
if (v < viewhist || v >= viewhist+VIEWHISTLEN) { |
340 |
< |
copystruct(viewhist + (nhist%VIEWHISTLEN), v); |
340 |
> |
*(viewhist + (nhist%VIEWHISTLEN)) = *v; |
341 |
|
nhist++; |
342 |
|
} |
343 |
|
} |
344 |
|
|
345 |
|
|
346 |
< |
int |
347 |
< |
usr_input() /* get user input and process it */ |
346 |
> |
static void |
347 |
> |
set_focus( /* set focus frame */ |
348 |
> |
char *args |
349 |
> |
) |
350 |
|
{ |
351 |
+ |
double hcent, vcent, hsiz, vsiz; |
352 |
+ |
VIEW *dv, vwfocus; |
353 |
+ |
int i, res[2]; |
354 |
+ |
|
355 |
+ |
i = sscanf(args, "%lf %lf %lf %lf", &hcent, &vcent, &hsiz, &vsiz); |
356 |
+ |
if (i < 2 || hcent < 0 || hcent > 1 || vcent < 0 || vcent > 1) { |
357 |
+ |
beam_init(0); /* restore view */ |
358 |
+ |
for (i = 0; (dv = dev_auxview(i, res)) != NULL; i++) |
359 |
+ |
beam_view(dv, res[0], res[1]); |
360 |
+ |
beam_sync(0); /* update server */ |
361 |
+ |
return; |
362 |
+ |
} |
363 |
+ |
if (i < 4 || hsiz <= hcent || hsiz > 1 || vsiz <= vcent || vsiz > 1) |
364 |
+ |
hsiz = vsiz = FSIZDEF; /* gave center only */ |
365 |
+ |
else { |
366 |
+ |
hsiz -= hcent; hcent += 0.5*hsiz; /* gave min and max */ |
367 |
+ |
vsiz -= vcent; vcent += 0.5*vsiz; |
368 |
+ |
} |
369 |
+ |
beam_init(0); /* add basic views */ |
370 |
+ |
for (i = 0; (dv = dev_auxview(i, res)) != NULL; i++) |
371 |
+ |
beam_view(dv, res[0]>>4, res[1]>>4); |
372 |
+ |
vwfocus = odev.v; /* add focus view */ |
373 |
+ |
switch (odev.v.type) { |
374 |
+ |
case VT_PER: |
375 |
+ |
vwfocus.horiz = 2.*180./PI*atan( |
376 |
+ |
hsiz * tan(PI/180./2.*odev.v.horiz) ); |
377 |
+ |
vwfocus.vert = 2.*180./PI*atan( |
378 |
+ |
vsiz * tan(PI/180./2.*odev.v.vert) ); |
379 |
+ |
break; |
380 |
+ |
case VT_PAR: |
381 |
+ |
case VT_ANG: |
382 |
+ |
vwfocus.horiz = hsiz * odev.v.horiz; |
383 |
+ |
vwfocus.vert = vsiz * odev.v.vert; |
384 |
+ |
break; |
385 |
+ |
case VT_PLS: |
386 |
+ |
vwfocus.horiz = hsiz * sin((PI/180./2.)*odev.v.horiz) / |
387 |
+ |
(1.0 + cos((PI/180./2.)*odev.v.horiz)); |
388 |
+ |
vwfocus.horiz *= vwfocus.horiz; |
389 |
+ |
vwfocus.horiz = (2.*180./PI)*acos((1. - vwfocus.horiz) / |
390 |
+ |
(1. + vwfocus.horiz)); |
391 |
+ |
vwfocus.vert = vsiz * sin((PI/180./2.)*odev.v.vert) / |
392 |
+ |
(1.0 + cos((PI/180./2.)*odev.v.vert)); |
393 |
+ |
vwfocus.vert *= vwfocus.vert; |
394 |
+ |
vwfocus.vert = (2.*180./PI)*acos((1. - vwfocus.vert) / |
395 |
+ |
(1. + vwfocus.vert)); |
396 |
+ |
break; |
397 |
+ |
case VT_HEM: |
398 |
+ |
vwfocus.horiz = 2.*180./PI*asin( |
399 |
+ |
hsiz * sin(PI/180./2.*odev.v.horiz) ); |
400 |
+ |
vwfocus.vert = 2.*180./PI*asin( |
401 |
+ |
vsiz * sin(PI/180./2.*odev.v.vert) ); |
402 |
+ |
break; |
403 |
+ |
case VT_CYL: |
404 |
+ |
vwfocus.horiz = hsiz * odev.v.horiz; |
405 |
+ |
vwfocus.vert = 2.*180./PI*atan( |
406 |
+ |
vsiz * tan(PI/180./2.*odev.v.vert) ); |
407 |
+ |
break; |
408 |
+ |
default: |
409 |
+ |
error(INTERNAL, "bad view type in set_focus"); |
410 |
+ |
} |
411 |
+ |
vwfocus.hoff = (odev.v.hoff + hcent - 0.5)/hsiz; |
412 |
+ |
vwfocus.voff = (odev.v.voff + vcent - 0.5)/vsiz; |
413 |
+ |
setview(&vwfocus); |
414 |
+ |
beam_view(&vwfocus, (int)(3*odev.hres*hsiz)+100, |
415 |
+ |
(int)(3*odev.vres*vsiz)+100); |
416 |
+ |
beam_sync(0); /* update server */ |
417 |
+ |
} |
418 |
+ |
|
419 |
+ |
|
420 |
+ |
static int |
421 |
+ |
usr_input(void) /* get user input and process it */ |
422 |
+ |
{ |
423 |
|
VIEW vparams; |
424 |
|
char cmd[256]; |
425 |
< |
register char *args; |
426 |
< |
register int i; |
425 |
> |
char *args; |
426 |
> |
int i; |
427 |
|
|
428 |
|
if (fgets(cmd, sizeof(cmd), sstdin) == NULL) { |
429 |
|
fclose(sstdin); |
447 |
|
} |
448 |
|
switch (i) { |
449 |
|
case DC_SETVIEW: /* set the view */ |
450 |
< |
copystruct(&vparams, &odev.v); |
450 |
> |
vparams = odev.v; |
451 |
|
if (!sscanview(&vparams, args)) |
452 |
|
error(COMMAND, "missing view options"); |
453 |
|
else |
459 |
|
case DC_LASTVIEW: /* restore previous view */ |
460 |
|
new_view(NULL); |
461 |
|
break; |
462 |
+ |
case DC_FOCUS: /* set focus frame */ |
463 |
+ |
set_focus(args); |
464 |
+ |
break; |
465 |
|
case DC_PAUSE: /* pause the current calculation */ |
466 |
|
case DC_RESUME: /* resume the calculation */ |
467 |
|
/* handled in main() */ |
489 |
|
} |
490 |
|
|
491 |
|
|
492 |
< |
printview() /* print our current view to server stdout */ |
492 |
> |
static void |
493 |
> |
printview(void) /* print our current view to server stdout */ |
494 |
|
{ |
495 |
|
fputs(VIEWSTR, sstdout); |
496 |
|
fprintview(&odev.v, sstdout); |
500 |
|
|
501 |
|
|
502 |
|
int |
503 |
< |
serv_result() /* get next server result and process it */ |
503 |
> |
serv_result(void) /* get next server result and process it */ |
504 |
|
{ |
505 |
|
static char *buf = NULL; |
506 |
|
static int bufsiz = 0; |
507 |
|
MSGHEAD msg; |
387 |
– |
int n; |
508 |
|
/* read message header */ |
509 |
< |
if (fread((char *)&msg, sizeof(MSGHEAD), 1, stdin) != 1) |
509 |
> |
if (getbinary(&msg, sizeof(MSGHEAD), 1, stdin) != 1) |
510 |
|
goto readerr; |
511 |
|
if (msg.nbytes > 0) { /* get the message body */ |
512 |
|
if (msg.nbytes > bufsiz) { |
513 |
|
if (buf == NULL) |
514 |
|
buf = (char *)malloc(bufsiz=msg.nbytes); |
515 |
|
else |
516 |
< |
buf = (char *)realloc(buf, bufsiz=msg.nbytes); |
516 |
> |
buf = (char *)realloc((void *)buf, |
517 |
> |
bufsiz=msg.nbytes); |
518 |
|
if (buf == NULL) |
519 |
|
error(SYSTEM, "out of memory in serv_result"); |
520 |
|
} |
521 |
< |
if (fread(buf, 1, msg.nbytes, stdin) != msg.nbytes) |
521 |
> |
if (getbinary(buf, 1, msg.nbytes, stdin) != msg.nbytes) |
522 |
|
goto readerr; |
523 |
|
} |
524 |
|
switch (msg.type) { /* process results */ |
529 |
|
disp_bundle((PACKHEAD *)buf); |
530 |
|
break; |
531 |
|
case DS_ADDHOLO: |
532 |
< |
if (msg.nbytes != sizeof(HDGRID)) |
532 |
> |
if (msg.nbytes < sizeof(HDGRID)+2) |
533 |
|
error(INTERNAL, "bad holodeck record from server"); |
534 |
< |
add_holo((HDGRID *)buf); |
534 |
> |
add_holo((HDGRID *)buf, buf+sizeof(HDGRID), |
535 |
> |
buf+sizeof(HDGRID)+strlen(buf+sizeof(HDGRID))+1); |
536 |
|
break; |
537 |
|
case DS_OUTSECT: |
538 |
|
do_outside = 1; |
543 |
|
break; |
544 |
|
case DS_STARTIMM: |
545 |
|
case DS_ENDIMM: |
546 |
+ |
if (!(imm_mode = (msg.type==DS_STARTIMM))) |
547 |
+ |
dev_flush(); |
548 |
|
#ifdef DEBUG |
549 |
< |
if (imm_mode != (msg.type==DS_STARTIMM)) { |
549 |
> |
{ |
550 |
|
time_t tnow = time(NULL); |
551 |
< |
if (imm_mode) timm += tnow - tmodesw; |
552 |
< |
else tadd += tnow - tmodesw; |
551 |
> |
if (msg.type==DS_STARTIMM) tadd += tnow - tmodesw; |
552 |
> |
else timm += tnow - tmodesw; |
553 |
|
tmodesw = tnow; |
554 |
|
} |
555 |
|
#endif |
432 |
– |
if (!(imm_mode = msg.type==DS_STARTIMM)) |
433 |
– |
dev_flush(); |
556 |
|
goto noargs; |
557 |
|
case DS_ACKNOW: |
558 |
|
case DS_SHUTDOWN: |
572 |
|
if (feof(stdin)) |
573 |
|
error(SYSTEM, "server process died"); |
574 |
|
error(SYSTEM, "error reading from server process"); |
575 |
+ |
return -1; |
576 |
|
} |
577 |
|
|
578 |
|
|
579 |
< |
serv_request(type, nbytes, p) /* send a request to the server process */ |
580 |
< |
int type, nbytes; |
581 |
< |
char *p; |
579 |
> |
void |
580 |
> |
serv_request( /* send a request to the server process */ |
581 |
> |
int type, |
582 |
> |
int nbytes, |
583 |
> |
char *p |
584 |
> |
) |
585 |
|
{ |
586 |
|
MSGHEAD msg; |
587 |
|
int m; |
588 |
|
/* consistency checks */ |
589 |
< |
#ifdef DEBUG |
590 |
< |
if (nbytes < 0 || nbytes > 0 & p == NULL) |
465 |
< |
error(CONSISTENCY, "bad buffer handed to serv_request"); |
466 |
< |
#endif |
589 |
> |
DCHECK(nbytes < 0 || nbytes > 0 & p == NULL, |
590 |
> |
CONSISTENCY, "bad buffer handed to serv_request"); |
591 |
|
/* get server's attention for big request */ |
592 |
|
if (nbytes >= BIGREQSIZ-sizeof(MSGHEAD)) { |
593 |
|
serv_request(DR_ATTEN, 0, NULL); |
597 |
|
} |
598 |
|
msg.type = type; /* write and flush the message */ |
599 |
|
msg.nbytes = nbytes; |
600 |
< |
fwrite((char *)&msg, sizeof(MSGHEAD), 1, stdout); |
600 |
> |
putbinary(&msg, sizeof(MSGHEAD), 1, stdout); |
601 |
|
if (nbytes > 0) |
602 |
< |
fwrite(p, 1, nbytes, stdout); |
602 |
> |
putbinary(p, 1, nbytes, stdout); |
603 |
|
if (fflush(stdout) < 0) |
604 |
|
error(SYSTEM, "write error in serv_request"); |
605 |
|
} |
606 |
|
|
607 |
|
|
608 |
< |
eputs(s) /* put error message to stderr */ |
609 |
< |
register char *s; |
608 |
> |
void |
609 |
> |
eputs( /* put error message to stderr */ |
610 |
> |
const char *s |
611 |
> |
) |
612 |
|
{ |
613 |
|
static int midline = 0; |
614 |
|
|
626 |
|
} |
627 |
|
|
628 |
|
|
629 |
< |
quit(code) /* clean up and exit */ |
630 |
< |
int code; |
629 |
> |
void |
630 |
> |
quit( /* clean up and exit */ |
631 |
> |
int code |
632 |
> |
) |
633 |
|
{ |
634 |
+ |
if (code) |
635 |
+ |
exit(code); |
636 |
|
if (odev.v.type) |
637 |
|
dev_close(); |
638 |
< |
exit(code); |
638 |
> |
exit(0); |
639 |
|
} |