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 = { |
35 |
|
int devchild; |
36 |
|
|
37 |
|
|
38 |
+ |
static struct driver * |
39 |
+ |
final_connect() /* verify and initialize connection */ |
40 |
+ |
{ |
41 |
+ |
putw(COM_SENDM, devout); |
42 |
+ |
fflush(devout); |
43 |
+ |
if (getw(devin) != COM_RECVM) |
44 |
+ |
return(NULL); |
45 |
+ |
/* get driver parameters */ |
46 |
+ |
getstate(); |
47 |
+ |
/* set error vectors */ |
48 |
+ |
cmdvec = comm_comout; |
49 |
+ |
if (wrnvec != NULL) |
50 |
+ |
wrnvec = comm_comout; |
51 |
+ |
return(&comm_driver); |
52 |
+ |
} |
53 |
+ |
|
54 |
+ |
|
55 |
|
struct driver * |
56 |
+ |
slave_init(dname, id) /* run rview in slave mode */ |
57 |
+ |
char *dname, *id; |
58 |
+ |
{ |
59 |
+ |
devchild = -1; /* we're the slave here */ |
60 |
+ |
devout = stdout; /* use standard input */ |
61 |
+ |
devin = stdin; /* and standard output */ |
62 |
+ |
return(final_connect()); /* verify initialization */ |
63 |
+ |
} |
64 |
+ |
|
65 |
+ |
|
66 |
+ |
struct driver * |
67 |
|
comm_init(dname, id) /* set up and execute driver */ |
68 |
|
char *dname, *id; |
69 |
|
{ |
96 |
|
goto syserr; |
97 |
|
if ((devin = fdopen(p2[0], "r")) == NULL) |
98 |
|
goto syserr; |
99 |
< |
/* 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); |
99 |
> |
return(final_connect()); /* verify initialization */ |
100 |
|
syserr: |
101 |
|
perror(dname); |
102 |
|
return(NULL); |
113 |
|
wrnvec = stderr_v; |
114 |
|
fclose(devout); |
115 |
|
fclose(devin); |
116 |
+ |
if (devchild < 0) |
117 |
+ |
return; |
118 |
|
while ((pid = wait(0)) != -1 && pid != devchild) |
119 |
|
; |
120 |
|
} |
201 |
|
reply_error("comin"); |
202 |
|
mygets(buf, devin); |
203 |
|
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 */ |
204 |
|
} |
205 |
|
|
206 |
|
|