--- ray/src/rt/devmain.c 1990/08/02 13:40:23 1.13 +++ ray/src/rt/devmain.c 2016/08/18 00:52:48 2.5 @@ -1,25 +1,20 @@ -/* Copyright (c) 1989 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: devmain.c,v 2.5 2016/08/18 00:52:48 greg Exp $"; #endif - /* * devmain.c - main for independent drivers. * * Redefine your initialization routine to dinit. - * - * 10/25/89 */ -#include +#include "copyright.h" +#include "standard.h" + #include "color.h" #include "driver.h" -int (*wrnvec)(), (*errvec)(), (*cmdvec)(); /* error vectors, unused */ - struct driver *dev = NULL; /* output device */ FILE *devin, *devout; /* communications channels */ @@ -44,13 +39,13 @@ char *argv[]; /* set up I/O */ progname = argv[0]; if (argc < 3) { - stderr_v("arg count\n"); + eputs("arg count\n"); quit(1); } devin = fdopen(atoi(argv[1]), "r"); devout = fdopen(atoi(argv[2]), "w"); if (devin == NULL || devout == NULL || getw(devin) != COM_SENDM) { - stderr_v("connection failure\n"); + eputs("connection failure\n"); quit(1); } /* open device */ @@ -62,7 +57,7 @@ char *argv[]; /* loop on requests */ while ((com = getc(devin)) != EOF) { if (com >= NREQUESTS || dev_func[com] == NULL) { - stderr_v("invalid request\n"); + eputs("invalid request\n"); quit(1); } (*dev_func[com])(); /* process request */ @@ -71,6 +66,7 @@ char *argv[]; } +void quit(code) /* close device and exit */ int code; { @@ -95,7 +91,7 @@ r_paintr() /* paint a rectangle */ COLOR col; int xmin, ymin, xmax, ymax; - fread((char *)col, sizeof(COLOR), 1, devin); + getbinary((char *)col, sizeof(COLOR), 1, devin); xmin = getw(devin); ymin = getw(devin); xmax = getw(devin); ymax = getw(devin); (*dev->paintr)(col, xmin, ymin, xmax, ymax); @@ -182,7 +178,8 @@ register FILE *fp; } -stderr_v(s) /* put string to stderr */ +void +eputs(s) /* put string to stderr */ register char *s; { static int midline = 0; @@ -203,7 +200,7 @@ register char *s; sendstate() /* send driver state variables */ { - fwrite((char *)&dev->pixaspect, sizeof(dev->pixaspect), 1, devout); + putbinary(&dev->pixaspect, sizeof(dev->pixaspect), 1, devout); putw(dev->xsiz, devout); putw(dev->ysiz, devout); putw(dev->inpready, devout);