16 |
|
|
17 |
|
#include "driver.h" |
18 |
|
|
19 |
+ |
#include "vfork.h" |
20 |
+ |
|
21 |
|
#ifndef DEVPATH |
22 |
|
#define DEVPATH getenv("PATH") /* device search path */ |
23 |
|
#endif |
24 |
|
|
25 |
< |
#ifndef BSD |
26 |
< |
#define vfork fork |
25 |
> |
#ifndef DELAY |
26 |
> |
#define DELAY 20 /* seconds to wait for response */ |
27 |
|
#endif |
28 |
|
|
29 |
< |
extern char *getpath(), *getenv(); |
28 |
< |
|
29 |
< |
int onsigio(); |
30 |
< |
|
31 |
< |
int comm_close(), comm_clear(), comm_paintr(), comm_errout(), |
29 |
> |
static int comm_close(), comm_clear(), comm_paintr(), comm_errout(), |
30 |
|
comm_getcur(), comm_comout(), comm_comin(), comm_flush(); |
31 |
|
|
32 |
|
struct driver comm_driver = { |
47 |
|
int p1[2], p2[2]; |
48 |
|
char pin[16], pout[16]; |
49 |
|
/* find driver program */ |
50 |
< |
if ((devname = getpath(dname, DEVPATH, 1)) == NULL) { |
50 |
> |
if ((devname = getpath(dname, DEVPATH, X_OK)) == NULL) { |
51 |
|
stderr_v(dname); |
52 |
|
stderr_v(": not found\n"); |
53 |
|
return(NULL); |
72 |
|
goto syserr; |
73 |
|
if ((devin = fdopen(p2[0], "r")) == NULL) |
74 |
|
goto syserr; |
75 |
< |
/* verify & get resolution */ |
75 |
> |
/* verify initialization */ |
76 |
|
putw(COM_SENDM, devout); |
77 |
|
fflush(devout); |
78 |
|
if (getw(devin) != COM_RECVM) |
79 |
|
return(NULL); |
80 |
< |
fread((char *)&comm_driver.pixaspect, |
81 |
< |
sizeof(comm_driver.pixaspect), 1, devin); |
84 |
< |
comm_driver.xsiz = getw(devin); |
85 |
< |
comm_driver.ysiz = getw(devin); |
80 |
> |
/* get driver parameters */ |
81 |
> |
getstate(); |
82 |
|
/* set error vectors */ |
83 |
|
cmdvec = comm_comout; |
84 |
|
if (wrnvec != NULL) |
137 |
|
fflush(devout); |
138 |
|
if (getc(devin) != COM_FLUSH) |
139 |
|
reply_error("flush"); |
140 |
< |
comm_driver.inpready = getw(devin); |
140 |
> |
getstate(); |
141 |
|
} |
142 |
|
|
143 |
|
|
164 |
|
{ |
165 |
|
putc(COM_COMOUT, devout); |
166 |
|
myputs(str, devout); |
167 |
+ |
if (str[strlen(str)-1] == '\n') |
168 |
+ |
fflush(devout); |
169 |
|
} |
170 |
|
|
171 |
|
|
185 |
|
if (getc(devin) != COM_COMIN) |
186 |
|
reply_error("comin"); |
187 |
|
mygets(buf, devin); |
188 |
< |
comm_driver.inpready = getw(devin); |
188 |
> |
getstate(); |
189 |
|
} |
190 |
|
|
191 |
|
|
230 |
|
stderr_v(routine); |
231 |
|
stderr_v(": driver reply error\n"); |
232 |
|
quit(1); |
233 |
+ |
} |
234 |
+ |
|
235 |
+ |
|
236 |
+ |
static |
237 |
+ |
getstate() /* get driver state variables */ |
238 |
+ |
{ |
239 |
+ |
fread((char *)&comm_driver.pixaspect, |
240 |
+ |
sizeof(comm_driver.pixaspect), 1, devin); |
241 |
+ |
comm_driver.xsiz = getw(devin); |
242 |
+ |
comm_driver.ysiz = getw(devin); |
243 |
+ |
comm_driver.inpready = getw(devin); |
244 |
|
} |