| 1 |
– |
/* Copyright (c) 1988 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 |
|
* devcomm.c - communication routines for separate drivers. |
| 6 |
|
* |
| 7 |
< |
* 10/5/88 |
| 7 |
> |
* External symbols declared in driver.h |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
+ |
/* ==================================================================== |
| 11 |
+ |
* The Radiance Software License, Version 1.0 |
| 12 |
+ |
* |
| 13 |
+ |
* Copyright (c) 1990 - 2002 The Regents of the University of California, |
| 14 |
+ |
* through Lawrence Berkeley National Laboratory. All rights reserved. |
| 15 |
+ |
* |
| 16 |
+ |
* Redistribution and use in source and binary forms, with or without |
| 17 |
+ |
* modification, are permitted provided that the following conditions |
| 18 |
+ |
* are met: |
| 19 |
+ |
* |
| 20 |
+ |
* 1. Redistributions of source code must retain the above copyright |
| 21 |
+ |
* notice, this list of conditions and the following disclaimer. |
| 22 |
+ |
* |
| 23 |
+ |
* 2. Redistributions in binary form must reproduce the above copyright |
| 24 |
+ |
* notice, this list of conditions and the following disclaimer in |
| 25 |
+ |
* the documentation and/or other materials provided with the |
| 26 |
+ |
* distribution. |
| 27 |
+ |
* |
| 28 |
+ |
* 3. The end-user documentation included with the redistribution, |
| 29 |
+ |
* if any, must include the following acknowledgment: |
| 30 |
+ |
* "This product includes Radiance software |
| 31 |
+ |
* (http://radsite.lbl.gov/) |
| 32 |
+ |
* developed by the Lawrence Berkeley National Laboratory |
| 33 |
+ |
* (http://www.lbl.gov/)." |
| 34 |
+ |
* Alternately, this acknowledgment may appear in the software itself, |
| 35 |
+ |
* if and wherever such third-party acknowledgments normally appear. |
| 36 |
+ |
* |
| 37 |
+ |
* 4. The names "Radiance," "Lawrence Berkeley National Laboratory" |
| 38 |
+ |
* and "The Regents of the University of California" must |
| 39 |
+ |
* not be used to endorse or promote products derived from this |
| 40 |
+ |
* software without prior written permission. For written |
| 41 |
+ |
* permission, please contact [email protected]. |
| 42 |
+ |
* |
| 43 |
+ |
* 5. Products derived from this software may not be called "Radiance", |
| 44 |
+ |
* nor may "Radiance" appear in their name, without prior written |
| 45 |
+ |
* permission of Lawrence Berkeley National Laboratory. |
| 46 |
+ |
* |
| 47 |
+ |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
| 48 |
+ |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 49 |
+ |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 50 |
+ |
* DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR |
| 51 |
+ |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 52 |
+ |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 53 |
+ |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 54 |
+ |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 55 |
+ |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 56 |
+ |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 57 |
+ |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 58 |
+ |
* SUCH DAMAGE. |
| 59 |
+ |
* ==================================================================== |
| 60 |
+ |
* |
| 61 |
+ |
* This software consists of voluntary contributions made by many |
| 62 |
+ |
* individuals on behalf of Lawrence Berkeley National Laboratory. For more |
| 63 |
+ |
* information on Lawrence Berkeley National Laboratory, please see |
| 64 |
+ |
* <http://www.lbl.gov/>. |
| 65 |
+ |
*/ |
| 66 |
+ |
|
| 67 |
|
#include "standard.h" |
| 68 |
|
|
| 69 |
|
#include "color.h" |
| 76 |
|
#define DEVPATH getenv("PATH") /* device search path */ |
| 77 |
|
#endif |
| 78 |
|
|
| 79 |
< |
static int comm_close(), comm_clear(), comm_paintr(), |
| 80 |
< |
comm_getcur(), comm_comout(), comm_comin(), comm_flush(); |
| 79 |
> |
static int comm_getcur(); |
| 80 |
> |
static void comm_close(), comm_clear(), comm_paintr(), |
| 81 |
> |
comm_comin(), comm_comout(), comm_flush(); |
| 82 |
|
|
| 83 |
|
struct driver comm_driver = { |
| 84 |
|
comm_close, comm_clear, comm_paintr, comm_getcur, |
| 85 |
|
comm_comout, comm_comin, comm_flush |
| 86 |
|
}; |
| 87 |
|
|
| 88 |
< |
static int mygets(), myputs(), reply_error(), getstate(); |
| 88 |
> |
static void mygets(), myputs(), reply_error(), getstate(); |
| 89 |
|
|
| 90 |
|
FILE *devin, *devout; |
| 91 |
|
|
| 124 |
|
comm_init(dname, id) /* set up and execute driver */ |
| 125 |
|
char *dname, *id; |
| 126 |
|
{ |
| 127 |
< |
char *devname; |
| 127 |
> |
char *dvcname; |
| 128 |
|
int p1[2], p2[2]; |
| 129 |
|
char pin[16], pout[16]; |
| 130 |
|
/* find driver program */ |
| 131 |
< |
if ((devname = getpath(dname, DEVPATH, X_OK)) == NULL) { |
| 131 |
> |
if ((dvcname = getpath(dname, DEVPATH, X_OK)) == NULL) { |
| 132 |
|
eputs(dname); |
| 133 |
|
eputs(": not found\n"); |
| 134 |
|
return(NULL); |
| 141 |
|
close(p2[0]); |
| 142 |
|
sprintf(pin, "%d", p1[0]); |
| 143 |
|
sprintf(pout, "%d", p2[1]); |
| 144 |
< |
execl(devname, dname, pin, pout, id, 0); |
| 145 |
< |
perror(devname); |
| 144 |
> |
execl(dvcname, dname, pin, pout, id, 0); |
| 145 |
> |
perror(dvcname); |
| 146 |
|
_exit(127); |
| 147 |
|
} |
| 148 |
|
if (devchild == -1) |
| 160 |
|
} |
| 161 |
|
|
| 162 |
|
|
| 163 |
< |
static |
| 163 |
> |
static void |
| 164 |
|
comm_close() /* done with driver */ |
| 165 |
|
{ |
| 166 |
|
int pid; |
| 177 |
|
} |
| 178 |
|
|
| 179 |
|
|
| 180 |
< |
static |
| 180 |
> |
static void |
| 181 |
|
comm_clear(xres, yres) /* clear screen */ |
| 182 |
|
int xres, yres; |
| 183 |
|
{ |
| 188 |
|
} |
| 189 |
|
|
| 190 |
|
|
| 191 |
< |
static |
| 191 |
> |
static void |
| 192 |
|
comm_paintr(col, xmin, ymin, xmax, ymax) /* paint a rectangle */ |
| 193 |
|
COLOR col; |
| 194 |
|
int xmin, ymin, xmax, ymax; |
| 202 |
|
} |
| 203 |
|
|
| 204 |
|
|
| 205 |
< |
static |
| 205 |
> |
static void |
| 206 |
|
comm_flush() /* flush output to driver */ |
| 207 |
|
{ |
| 208 |
|
putc(COM_FLUSH, devout); |
| 230 |
|
} |
| 231 |
|
|
| 232 |
|
|
| 233 |
< |
static |
| 233 |
> |
static void |
| 234 |
|
comm_comout(str) /* print string to command line */ |
| 235 |
|
char *str; |
| 236 |
|
{ |
| 241 |
|
} |
| 242 |
|
|
| 243 |
|
|
| 244 |
< |
static |
| 244 |
> |
static void |
| 245 |
|
comm_comin(buf, prompt) /* read string from command line */ |
| 246 |
|
char *buf; |
| 247 |
|
char *prompt; |
| 261 |
|
} |
| 262 |
|
|
| 263 |
|
|
| 264 |
< |
static |
| 264 |
> |
static void |
| 265 |
|
mygets(s, fp) /* get string from file (with nul) */ |
| 266 |
|
register char *s; |
| 267 |
|
register FILE *fp; |
| 275 |
|
} |
| 276 |
|
|
| 277 |
|
|
| 278 |
< |
static |
| 278 |
> |
static void |
| 279 |
|
myputs(s, fp) /* put string to file (with nul) */ |
| 280 |
|
register char *s; |
| 281 |
|
register FILE *fp; |
| 286 |
|
} |
| 287 |
|
|
| 288 |
|
|
| 289 |
< |
static |
| 289 |
> |
static void |
| 290 |
|
reply_error(routine) /* what should we do here? */ |
| 291 |
|
char *routine; |
| 292 |
|
{ |
| 296 |
|
} |
| 297 |
|
|
| 298 |
|
|
| 299 |
< |
static |
| 299 |
> |
static void |
| 300 |
|
getstate() /* get driver state variables */ |
| 301 |
|
{ |
| 302 |
|
fread((char *)&comm_driver.pixaspect, |