| 1 |
< |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
| 1 |
> |
/* Copyright (c) 1999 Silicon Graphics, Inc. */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
| 13 |
|
#include <sys/uio.h> |
| 14 |
|
|
| 15 |
|
#ifndef HDSUF |
| 16 |
< |
#define HDSUF ".hdi" |
| 16 |
> |
#define HDSUF ".hdi" |
| 17 |
|
#endif |
| 18 |
+ |
#ifndef SLAVENAME |
| 19 |
+ |
#define SLAVENAME "slave" |
| 20 |
+ |
#endif |
| 21 |
|
|
| 22 |
|
#ifndef FNONBLK |
| 23 |
|
#define FNONBLK O_NONBLOCK |
| 31 |
|
disp_open(dname) /* open the named display driver */ |
| 32 |
|
char *dname; |
| 33 |
|
{ |
| 34 |
< |
char buf[128], fd0[8], fd1[8], *cmd[5], *ofn; |
| 35 |
< |
int i, n; |
| 36 |
< |
/* get full display program name */ |
| 34 |
> |
char buf[sizeof(HDGRID)+512], fd0[8], fd1[8], *cmd[5], *sfn; |
| 35 |
> |
int i, n, len; |
| 36 |
> |
|
| 37 |
> |
if (!strcmp(dname, SLAVENAME)) { |
| 38 |
> |
dpd[0] = 0; /* read from stdin */ |
| 39 |
> |
dpout = stdout; /* write to stdout */ |
| 40 |
> |
dpd[2] = -1; /* we're the slave process */ |
| 41 |
> |
} else { |
| 42 |
> |
/* get full display program name */ |
| 43 |
|
#ifdef DEVPATH |
| 44 |
< |
sprintf(buf, "%s/%s%s", DEVPATH, dname, HDSUF); |
| 44 |
> |
sprintf(buf, "%s/%s%s", DEVPATH, dname, HDSUF); |
| 45 |
|
#else |
| 46 |
< |
sprintf(buf, "dev/%s%s", dname, HDSUF); |
| 46 |
> |
sprintf(buf, "dev/%s%s", dname, HDSUF); |
| 47 |
|
#endif |
| 48 |
< |
/* dup stdin and stdout */ |
| 49 |
< |
if (readinp) |
| 50 |
< |
sprintf(fd0, "%d", dup(0)); |
| 51 |
< |
else |
| 52 |
< |
strcpy(fd0, "-1"); |
| 53 |
< |
sprintf(fd1, "%d", dup(1)); |
| 54 |
< |
/* start the display process */ |
| 55 |
< |
cmd[0] = buf; |
| 56 |
< |
cmd[1] = froot; cmd[2] = fd1; cmd[3] = fd0; |
| 57 |
< |
cmd[4] = NULL; |
| 58 |
< |
i = open_process(dpd, cmd); |
| 59 |
< |
if (i <= 0) |
| 60 |
< |
error(USER, "cannot start display process"); |
| 61 |
< |
if ((dpout = fdopen(dpd[1], "w")) == NULL) |
| 62 |
< |
error(SYSTEM, "cannot associate FILE with display pipe"); |
| 48 |
> |
/* dup stdin and stdout */ |
| 49 |
> |
if (readinp) |
| 50 |
> |
sprintf(fd0, "%d", dup(0)); |
| 51 |
> |
else |
| 52 |
> |
strcpy(fd0, "-1"); |
| 53 |
> |
sprintf(fd1, "%d", dup(1)); |
| 54 |
> |
/* start the display process */ |
| 55 |
> |
cmd[0] = buf; |
| 56 |
> |
cmd[1] = froot; cmd[2] = fd1; cmd[3] = fd0; |
| 57 |
> |
cmd[4] = NULL; |
| 58 |
> |
i = open_process(dpd, cmd); |
| 59 |
> |
if (i <= 0) |
| 60 |
> |
error(USER, "cannot start display process"); |
| 61 |
> |
if ((dpout = fdopen(dpd[1], "w")) == NULL) |
| 62 |
> |
error(SYSTEM, "problem opening display pipe"); |
| 63 |
> |
/* close dup'ed stdin and stdout */ |
| 64 |
> |
if (readinp) |
| 65 |
> |
close(atoi(fd0)); |
| 66 |
> |
close(atoi(fd1)); |
| 67 |
> |
} |
| 68 |
|
dpd[1] = -1; /* causes ignored error in close_process() */ |
| 69 |
|
inp_flags = 0; |
| 56 |
– |
/* close dup'ed stdin and stdout */ |
| 57 |
– |
if (readinp) |
| 58 |
– |
close(atoi(fd0)); |
| 59 |
– |
close(atoi(fd1)); |
| 70 |
|
/* check if outside */ |
| 71 |
|
if (vdef(OBSTRUCTIONS) && vbool(OBSTRUCTIONS)) |
| 72 |
|
disp_result(DS_OUTSECT, 0, NULL); |
| 78 |
|
/* write out hologram grids & octrees */ |
| 79 |
|
for (i = 0; hdlist[i] != NULL; i++) { |
| 80 |
|
bcopy((char *)hdlist[i], buf, sizeof(HDGRID)); |
| 81 |
< |
n = vdef(OSECTION); |
| 82 |
< |
ofn = i<n ? nvalue(OSECTION,i) : |
| 83 |
< |
n ? nvalue(OSECTION,n-1) : vval(OCTREE); |
| 84 |
< |
strcpy(buf+sizeof(HDGRID), ofn); |
| 85 |
< |
disp_result(DS_ADDHOLO, sizeof(HDGRID)+1+strlen(ofn), buf); |
| 81 |
> |
len = sizeof(HDGRID); |
| 82 |
> |
n = vdef(GEOMETRY); |
| 83 |
> |
sfn = i<n ? nvalue(GEOMETRY,i) : |
| 84 |
> |
n ? nvalue(GEOMETRY,n-1) : vval(OCTREE); |
| 85 |
> |
strcpy(buf+len, sfn); |
| 86 |
> |
len += strlen(sfn) + 1; |
| 87 |
> |
n = vdef(PORTS); |
| 88 |
> |
sfn = i<n ? nvalue(PORTS,i) : n ? nvalue(PORTS,n-1) : ""; |
| 89 |
> |
strcpy(buf+len, sfn); |
| 90 |
> |
len += strlen(sfn) + 1; |
| 91 |
> |
disp_result(DS_ADDHOLO, len, buf); |
| 92 |
|
} |
| 93 |
|
disp_flush(); |
| 94 |
|
} |
| 253 |
|
disp_result(DS_SHUTDOWN, 0, NULL); |
| 254 |
|
fclose(dpout); |
| 255 |
|
dpout = NULL; |
| 256 |
< |
return(close_process(dpd)); |
| 256 |
> |
return(dpd[2]<0 ? 0 : close_process(dpd)); |
| 257 |
|
} |
| 258 |
|
|
| 259 |
|
|