| 22 |
|
#define DEVPATH getenv("PATH") /* device search path */ |
| 23 |
|
#endif |
| 24 |
|
|
| 25 |
< |
#ifndef DELAY |
| 26 |
< |
#define DELAY 20 /* seconds to wait for response */ |
| 27 |
< |
#endif |
| 28 |
< |
|
| 29 |
< |
static int comm_close(), comm_clear(), comm_paintr(), comm_errout(), |
| 25 |
> |
static int comm_close(), comm_clear(), comm_paintr(), |
| 26 |
|
comm_getcur(), comm_comout(), comm_comin(), comm_flush(); |
| 27 |
|
|
| 28 |
|
struct driver comm_driver = { |
| 30 |
|
comm_comout, comm_comin, comm_flush |
| 31 |
|
}; |
| 32 |
|
|
| 33 |
+ |
static int mygets(), myputs(), reply_error(), getstate(); |
| 34 |
+ |
|
| 35 |
|
FILE *devin, *devout; |
| 36 |
|
|
| 37 |
|
int devchild; |
| 38 |
|
|
| 39 |
|
|
| 40 |
+ |
static struct driver * |
| 41 |
+ |
final_connect() /* verify and initialize connection */ |
| 42 |
+ |
{ |
| 43 |
+ |
putw(COM_SENDM, devout); |
| 44 |
+ |
fflush(devout); |
| 45 |
+ |
if (getw(devin) != COM_RECVM) |
| 46 |
+ |
return(NULL); |
| 47 |
+ |
/* get driver parameters */ |
| 48 |
+ |
getstate(); |
| 49 |
+ |
/* set error vectors */ |
| 50 |
+ |
cmdvec = comm_comout; |
| 51 |
+ |
if (wrnvec != NULL) |
| 52 |
+ |
wrnvec = comm_comout; |
| 53 |
+ |
return(&comm_driver); |
| 54 |
+ |
} |
| 55 |
+ |
|
| 56 |
+ |
|
| 57 |
|
struct driver * |
| 58 |
+ |
slave_init(dname, id) /* run rview in slave mode */ |
| 59 |
+ |
char *dname, *id; |
| 60 |
+ |
{ |
| 61 |
+ |
devchild = -1; /* we're the slave here */ |
| 62 |
+ |
devout = stdout; /* use standard input */ |
| 63 |
+ |
devin = stdin; /* and standard output */ |
| 64 |
+ |
return(final_connect()); /* verify initialization */ |
| 65 |
+ |
} |
| 66 |
+ |
|
| 67 |
+ |
|
| 68 |
+ |
struct driver * |
| 69 |
|
comm_init(dname, id) /* set up and execute driver */ |
| 70 |
|
char *dname, *id; |
| 71 |
|
{ |
| 98 |
|
goto syserr; |
| 99 |
|
if ((devin = fdopen(p2[0], "r")) == NULL) |
| 100 |
|
goto syserr; |
| 101 |
< |
/* verify initialization */ |
| 76 |
< |
putw(COM_SENDM, devout); |
| 77 |
< |
fflush(devout); |
| 78 |
< |
if (getw(devin) != COM_RECVM) |
| 79 |
< |
return(NULL); |
| 80 |
< |
/* get driver parameters */ |
| 81 |
< |
getstate(); |
| 82 |
< |
/* set error vectors */ |
| 83 |
< |
cmdvec = comm_comout; |
| 84 |
< |
if (wrnvec != NULL) |
| 85 |
< |
wrnvec = comm_comout; |
| 86 |
< |
return(&comm_driver); |
| 101 |
> |
return(final_connect()); /* verify initialization */ |
| 102 |
|
syserr: |
| 103 |
|
perror(dname); |
| 104 |
|
return(NULL); |
| 115 |
|
wrnvec = stderr_v; |
| 116 |
|
fclose(devout); |
| 117 |
|
fclose(devin); |
| 118 |
+ |
if (devchild < 0) |
| 119 |
+ |
return; |
| 120 |
|
while ((pid = wait(0)) != -1 && pid != devchild) |
| 121 |
|
; |
| 122 |
|
} |
| 203 |
|
reply_error("comin"); |
| 204 |
|
mygets(buf, devin); |
| 205 |
|
getstate(); |
| 189 |
– |
} |
| 190 |
– |
|
| 191 |
– |
|
| 192 |
– |
static |
| 193 |
– |
comm_errout(str) /* display an error message */ |
| 194 |
– |
char *str; |
| 195 |
– |
{ |
| 196 |
– |
comm_comout(str); |
| 197 |
– |
stderr_v(str); /* send to standard error also */ |
| 206 |
|
} |
| 207 |
|
|
| 208 |
|
|