| 1 |
– |
/* Copyright (c) 1989 Regents of the University of California */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* devmain.c - main for independent drivers. |
| 6 |
|
* |
| 7 |
|
* Redefine your initialization routine to dinit. |
| 11 |
– |
* |
| 12 |
– |
* 10/25/89 |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
< |
#include <stdio.h> |
| 10 |
> |
#include "copyright.h" |
| 11 |
|
|
| 12 |
+ |
#include "standard.h" |
| 13 |
+ |
|
| 14 |
|
#include "color.h" |
| 15 |
|
|
| 16 |
|
#include "driver.h" |
| 17 |
|
|
| 21 |
– |
int (*wrnvec)(), (*errvec)(), (*cmdvec)(); /* error vectors, unused */ |
| 22 |
– |
|
| 18 |
|
struct driver *dev = NULL; /* output device */ |
| 19 |
|
|
| 20 |
|
FILE *devin, *devout; /* communications channels */ |
| 39 |
|
/* set up I/O */ |
| 40 |
|
progname = argv[0]; |
| 41 |
|
if (argc < 3) { |
| 42 |
< |
stderr_v("arg count\n"); |
| 42 |
> |
eputs("arg count\n"); |
| 43 |
|
quit(1); |
| 44 |
|
} |
| 45 |
|
devin = fdopen(atoi(argv[1]), "r"); |
| 46 |
|
devout = fdopen(atoi(argv[2]), "w"); |
| 47 |
|
if (devin == NULL || devout == NULL || getw(devin) != COM_SENDM) { |
| 48 |
< |
stderr_v("connection failure\n"); |
| 48 |
> |
eputs("connection failure\n"); |
| 49 |
|
quit(1); |
| 50 |
|
} |
| 51 |
|
/* open device */ |
| 57 |
|
/* loop on requests */ |
| 58 |
|
while ((com = getc(devin)) != EOF) { |
| 59 |
|
if (com >= NREQUESTS || dev_func[com] == NULL) { |
| 60 |
< |
stderr_v("invalid request\n"); |
| 60 |
> |
eputs("invalid request\n"); |
| 61 |
|
quit(1); |
| 62 |
|
} |
| 63 |
|
(*dev_func[com])(); /* process request */ |
| 66 |
|
} |
| 67 |
|
|
| 68 |
|
|
| 69 |
+ |
void |
| 70 |
|
quit(code) /* close device and exit */ |
| 71 |
|
int code; |
| 72 |
|
{ |
| 178 |
|
} |
| 179 |
|
|
| 180 |
|
|
| 181 |
< |
stderr_v(s) /* put string to stderr */ |
| 181 |
> |
void |
| 182 |
> |
eputs(s) /* put string to stderr */ |
| 183 |
|
register char *s; |
| 184 |
|
{ |
| 185 |
|
static int midline = 0; |