--- ray/src/rt/devcomm.c 1993/11/18 09:42:58 2.4 +++ ray/src/rt/devcomm.c 2003/11/10 16:52:25 2.10 @@ -1,36 +1,36 @@ -/* Copyright (c) 1988 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: devcomm.c,v 2.10 2003/11/10 16:52:25 greg Exp $"; #endif - /* * devcomm.c - communication routines for separate drivers. * - * 10/5/88 + * External symbols declared in driver.h */ +#include "copyright.h" + +#include "platform.h" + #include "standard.h" -#include "color.h" +#include "paths.h" #include "driver.h" -#include "vfork.h" - #ifndef DEVPATH #define DEVPATH getenv("PATH") /* device search path */ #endif -static int comm_close(), comm_clear(), comm_paintr(), - comm_getcur(), comm_comout(), comm_comin(), comm_flush(); +static int comm_getcur(); +static void comm_close(), comm_clear(), comm_paintr(), + comm_comin(), comm_comout(), comm_flush(); struct driver comm_driver = { comm_close, comm_clear, comm_paintr, comm_getcur, comm_comout, comm_comin, comm_flush }; -static int mygets(), myputs(), reply_error(), getstate(); +static void mygets(), myputs(), reply_error(), getstate(); FILE *devin, *devout; @@ -47,9 +47,9 @@ final_connect() /* verify and initialize connection /* get driver parameters */ getstate(); /* set error vectors */ - cmdvec = comm_comout; - if (wrnvec != NULL) - wrnvec = comm_comout; + erract[COMMAND].pf = comm_comout; + if (erract[WARNING].pf != NULL) + erract[WARNING].pf = comm_comout; return(&comm_driver); } @@ -69,15 +69,16 @@ struct driver * comm_init(dname, id) /* set up and execute driver */ char *dname, *id; { - char *devname; + char *dvcname; int p1[2], p2[2]; char pin[16], pout[16]; /* find driver program */ - if ((devname = getpath(dname, DEVPATH, X_OK)) == NULL) { - stderr_v(dname); - stderr_v(": not found\n"); + if ((dvcname = getpath(dname, DEVPATH, X_OK)) == NULL) { + eputs(dname); + eputs(": not found\n"); return(NULL); } +#ifdef RHAS_FORK_EXEC /* open communication pipes */ if (pipe(p1) == -1 || pipe(p2) == -1) goto syserr; @@ -86,8 +87,8 @@ char *dname, *id; close(p2[0]); sprintf(pin, "%d", p1[0]); sprintf(pout, "%d", p2[1]); - execl(devname, dname, pin, pout, id, 0); - perror(devname); + execl(dvcname, dname, pin, pout, id, 0); + perror(dvcname); _exit(127); } if (devchild == -1) @@ -102,17 +103,25 @@ char *dname, *id; syserr: perror(dname); return(NULL); + +#else /* ! RHAS_FORK_EXEC */ + + eputs(dname); + eputs(": no fork/exec\n"); + return(NULL); + +#endif /* ! RHAS_FORK_EXEC */ } -static +static void comm_close() /* done with driver */ { int pid; - cmdvec = NULL; /* reset error vectors */ - if (wrnvec != NULL) - wrnvec = stderr_v; + erract[COMMAND].pf = NULL; /* reset error vectors */ + if (erract[WARNING].pf != NULL) + erract[WARNING].pf = wputs; fclose(devout); fclose(devin); if (devchild < 0) @@ -122,7 +131,7 @@ comm_close() /* done with driver */ } -static +static void comm_clear(xres, yres) /* clear screen */ int xres, yres; { @@ -133,7 +142,7 @@ int xres, yres; } -static +static void comm_paintr(col, xmin, ymin, xmax, ymax) /* paint a rectangle */ COLOR col; int xmin, ymin, xmax, ymax; @@ -147,7 +156,7 @@ int xmin, ymin, xmax, ymax; } -static +static void comm_flush() /* flush output to driver */ { putc(COM_FLUSH, devout); @@ -175,7 +184,7 @@ int *xp, *yp; } -static +static void comm_comout(str) /* print string to command line */ char *str; { @@ -186,7 +195,7 @@ char *str; } -static +static void comm_comin(buf, prompt) /* read string from command line */ char *buf; char *prompt; @@ -206,7 +215,7 @@ char *prompt; } -static +static void mygets(s, fp) /* get string from file (with nul) */ register char *s; register FILE *fp; @@ -220,7 +229,7 @@ register FILE *fp; } -static +static void myputs(s, fp) /* put string to file (with nul) */ register char *s; register FILE *fp; @@ -231,17 +240,17 @@ register FILE *fp; } -static +static void reply_error(routine) /* what should we do here? */ char *routine; { - stderr_v(routine); - stderr_v(": driver reply error\n"); + eputs(routine); + eputs(": driver reply error\n"); quit(1); } -static +static void getstate() /* get driver state variables */ { fread((char *)&comm_driver.pixaspect,