9 |
|
|
10 |
|
#include "copyright.h" |
11 |
|
|
12 |
< |
#include "platform.h" |
12 |
> |
#include <sys/types.h> |
13 |
> |
#include <sys/wait.h> /* XXX platform specific */ |
14 |
|
|
15 |
+ |
#include "platform.h" |
16 |
|
#include "standard.h" |
15 |
– |
|
17 |
|
#include "driver.h" |
18 |
|
|
19 |
|
#ifndef DEVPATH |
20 |
|
#define DEVPATH getenv("PATH") /* device search path */ |
21 |
|
#endif |
22 |
|
|
23 |
< |
static int comm_getcur(); |
24 |
< |
static void comm_close(), comm_clear(), comm_paintr(), |
24 |
< |
comm_comin(), comm_comout(), comm_flush(); |
23 |
> |
FILE *devin, *devout; |
24 |
> |
int devchild; |
25 |
|
|
26 |
+ |
static struct driver * final_connect(void); |
27 |
+ |
static void mygets(char *s, FILE *fp); |
28 |
+ |
static void myputs(char *s, FILE *fp); |
29 |
+ |
static void reply_error(char *routine); |
30 |
+ |
static void getstate(void); |
31 |
+ |
|
32 |
+ |
static dr_closef_t comm_close; |
33 |
+ |
static dr_clearf_t comm_clear; |
34 |
+ |
static dr_paintrf_t comm_paintr; |
35 |
+ |
static dr_getcurf_t comm_getcur; |
36 |
+ |
static dr_comoutf_t comm_comout; |
37 |
+ |
static dr_cominf_t comm_comin; |
38 |
+ |
static dr_flushf_t comm_flush; |
39 |
+ |
|
40 |
|
struct driver comm_driver = { |
41 |
|
comm_close, comm_clear, comm_paintr, comm_getcur, |
42 |
|
comm_comout, comm_comin, comm_flush |
43 |
|
}; |
44 |
|
|
31 |
– |
static void mygets(), myputs(), reply_error(), getstate(); |
45 |
|
|
33 |
– |
FILE *devin, *devout; |
34 |
– |
|
35 |
– |
int devchild; |
36 |
– |
|
37 |
– |
|
46 |
|
static struct driver * |
47 |
< |
final_connect() /* verify and initialize connection */ |
47 |
> |
final_connect(void) /* verify and initialize connection */ |
48 |
|
{ |
49 |
|
putw(COM_SENDM, devout); |
50 |
|
fflush(devout); |
60 |
|
} |
61 |
|
|
62 |
|
|
63 |
< |
struct driver * |
64 |
< |
slave_init(dname, id) /* run rview in slave mode */ |
65 |
< |
char *dname, *id; |
63 |
> |
extern struct driver * |
64 |
> |
slave_init( /* run rview in slave mode */ |
65 |
> |
char *dname, |
66 |
> |
char *id |
67 |
> |
) |
68 |
|
{ |
69 |
|
devchild = -1; /* we're the slave here */ |
70 |
|
devout = stdout; /* use standard input */ |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
< |
struct driver * |
77 |
< |
comm_init(dname, id) /* set up and execute driver */ |
78 |
< |
char *dname, *id; |
76 |
> |
extern struct driver * |
77 |
> |
comm_init( /* set up and execute driver */ |
78 |
> |
char *dname, |
79 |
> |
char *id |
80 |
> |
) |
81 |
|
{ |
82 |
|
char *dvcname; |
83 |
|
int p1[2], p2[2]; |
125 |
|
|
126 |
|
|
127 |
|
static void |
128 |
< |
comm_close() /* done with driver */ |
128 |
> |
comm_close(void) /* done with driver */ |
129 |
|
{ |
130 |
|
int pid; |
131 |
|
|
142 |
|
|
143 |
|
|
144 |
|
static void |
145 |
< |
comm_clear(xres, yres) /* clear screen */ |
146 |
< |
int xres, yres; |
145 |
> |
comm_clear( /* clear screen */ |
146 |
> |
int xres, |
147 |
> |
int yres |
148 |
> |
) |
149 |
|
{ |
150 |
|
putc(COM_CLEAR, devout); |
151 |
|
putw(xres, devout); |
155 |
|
|
156 |
|
|
157 |
|
static void |
158 |
< |
comm_paintr(col, xmin, ymin, xmax, ymax) /* paint a rectangle */ |
159 |
< |
COLOR col; |
160 |
< |
int xmin, ymin, xmax, ymax; |
158 |
> |
comm_paintr( /* paint a rectangle */ |
159 |
> |
COLOR col, |
160 |
> |
int xmin, |
161 |
> |
int ymin, |
162 |
> |
int xmax, |
163 |
> |
int ymax |
164 |
> |
) |
165 |
|
{ |
166 |
|
putc(COM_PAINTR, devout); |
167 |
|
fwrite((char *)col, sizeof(COLOR), 1, devout); |
173 |
|
|
174 |
|
|
175 |
|
static void |
176 |
< |
comm_flush() /* flush output to driver */ |
176 |
> |
comm_flush(void) /* flush output to driver */ |
177 |
|
{ |
178 |
|
putc(COM_FLUSH, devout); |
179 |
|
fflush(devout); |
184 |
|
|
185 |
|
|
186 |
|
static int |
187 |
< |
comm_getcur(xp, yp) /* get and return cursor position */ |
188 |
< |
int *xp, *yp; |
187 |
> |
comm_getcur( /* get and return cursor position */ |
188 |
> |
int *xp, |
189 |
> |
int *yp |
190 |
> |
) |
191 |
|
{ |
192 |
|
int c; |
193 |
|
|
203 |
|
|
204 |
|
|
205 |
|
static void |
206 |
< |
comm_comout(str) /* print string to command line */ |
207 |
< |
char *str; |
206 |
> |
comm_comout( /* print string to command line */ |
207 |
> |
char *str |
208 |
> |
) |
209 |
|
{ |
210 |
|
putc(COM_COMOUT, devout); |
211 |
|
myputs(str, devout); |
215 |
|
|
216 |
|
|
217 |
|
static void |
218 |
< |
comm_comin(buf, prompt) /* read string from command line */ |
219 |
< |
char *buf; |
220 |
< |
char *prompt; |
218 |
> |
comm_comin( /* read string from command line */ |
219 |
> |
char *buf, |
220 |
> |
char *prompt |
221 |
> |
) |
222 |
|
{ |
223 |
|
putc(COM_COMIN, devout); |
224 |
|
if (prompt == NULL) |
236 |
|
|
237 |
|
|
238 |
|
static void |
239 |
< |
mygets(s, fp) /* get string from file (with nul) */ |
240 |
< |
register char *s; |
241 |
< |
register FILE *fp; |
239 |
> |
mygets( /* get string from file (with nul) */ |
240 |
> |
register char *s, |
241 |
> |
register FILE *fp |
242 |
> |
) |
243 |
|
{ |
244 |
|
register int c; |
245 |
|
|
251 |
|
|
252 |
|
|
253 |
|
static void |
254 |
< |
myputs(s, fp) /* put string to file (with nul) */ |
255 |
< |
register char *s; |
256 |
< |
register FILE *fp; |
254 |
> |
myputs( /* put string to file (with nul) */ |
255 |
> |
register char *s, |
256 |
> |
register FILE *fp |
257 |
> |
) |
258 |
|
{ |
259 |
|
do |
260 |
|
putc(*s, fp); |
263 |
|
|
264 |
|
|
265 |
|
static void |
266 |
< |
reply_error(routine) /* what should we do here? */ |
267 |
< |
char *routine; |
266 |
> |
reply_error( /* what should we do here? */ |
267 |
> |
char *routine |
268 |
> |
) |
269 |
|
{ |
270 |
|
eputs(routine); |
271 |
|
eputs(": driver reply error\n"); |
274 |
|
|
275 |
|
|
276 |
|
static void |
277 |
< |
getstate() /* get driver state variables */ |
277 |
> |
getstate(void) /* get driver state variables */ |
278 |
|
{ |
279 |
|
fread((char *)&comm_driver.pixaspect, |
280 |
|
sizeof(comm_driver.pixaspect), 1, devin); |