| 1 |
– |
/* Copyright (c) 1995 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 |
|
* Generate sections of a picture. |
| 6 |
|
*/ |
| 20 |
|
#else |
| 21 |
|
|
| 22 |
|
#include <signal.h> |
| 23 |
+ |
|
| 24 |
|
#include "color.h" |
| 25 |
|
#include "view.h" |
| 26 |
< |
#include "resolu.h" |
| 26 |
> |
#include "rtprocess.h" |
| 27 |
|
|
| 28 |
|
#ifndef NFS |
| 29 |
|
#define NFS 1 |
| 46 |
|
#define unguard() 0 |
| 47 |
|
#endif |
| 48 |
|
|
| 49 |
< |
#ifndef linux |
| 52 |
< |
extern char *sys_errlist[]; |
| 53 |
< |
#endif |
| 49 |
> |
extern char *strerror(); |
| 50 |
|
|
| 51 |
|
/* rpict command */ |
| 52 |
|
char *rpargv[128] = {"rpict", "-S", "1"}; |
| 53 |
|
int rpargc = 3; |
| 58 |
– |
int rpd[3]; |
| 54 |
|
FILE *torp, *fromrp; |
| 55 |
|
COLR *pbuf; |
| 56 |
|
/* our view parameters */ |
| 73 |
|
int rvrlim = -1; |
| 74 |
|
|
| 75 |
|
int gotalrm = 0; |
| 76 |
< |
int onalrm() { gotalrm++; } |
| 76 |
> |
void onalrm(int i) { gotalrm++; } |
| 77 |
|
|
| 78 |
|
|
| 79 |
|
main(argc, argv) |
| 85 |
|
progname = argv[0]; |
| 86 |
|
for (i = 1; i < argc; i++) { |
| 87 |
|
/* expand arguments */ |
| 88 |
< |
while (rval = expandarg(&argc, &argv, i)) |
| 89 |
< |
if (rval < 0) { |
| 90 |
< |
fprintf(stderr, "%s: cannot expand '%s'", |
| 91 |
< |
argv[0], argv[i]); |
| 92 |
< |
exit(1); |
| 93 |
< |
} |
| 88 |
> |
while ((rval = expandarg(&argc, &argv, i)) > 0) |
| 89 |
> |
; |
| 90 |
> |
if (rval < 0) { |
| 91 |
> |
fprintf(stderr, "%s: cannot expand '%s'", |
| 92 |
> |
argv[0], argv[i]); |
| 93 |
> |
exit(1); |
| 94 |
> |
} |
| 95 |
|
if (argv[i][0] == '-') |
| 96 |
|
switch (argv[i][1]) { |
| 97 |
|
case 'v': |
| 196 |
|
fls.l_type = ltyp; |
| 197 |
|
if (fcntl(fd, F_SETLKW, &fls) < 0) { |
| 198 |
|
fprintf(stderr, "%s: cannot lock/unlock file: %s\n", |
| 199 |
< |
progname, sys_errlist[errno]); |
| 199 |
> |
progname, strerror(errno)); |
| 200 |
|
exit(1); |
| 201 |
|
} |
| 202 |
|
} |
| 211 |
|
char *err; |
| 212 |
|
FILE *fp; |
| 213 |
|
int hr, vr; |
| 214 |
+ |
SUBPROC rpd; /* since we don't close_process(), this can be local */ |
| 215 |
|
/* set up view */ |
| 216 |
|
if ((err = setview(&ourview)) != NULL) { |
| 217 |
|
fprintf(stderr, "%s: %s\n", progname, err); |
| 270 |
|
goto filerr; |
| 271 |
|
dolock(outfd, F_UNLCK); |
| 272 |
|
/* start rpict process */ |
| 273 |
< |
if (open_process(rpd, rpargv) <= 0) { |
| 273 |
> |
if (open_process(&rpd, rpargv) <= 0) { |
| 274 |
|
fprintf(stderr, "%s: cannot start %s\n", progname, rpargv[0]); |
| 275 |
|
exit(1); |
| 276 |
|
} |
| 277 |
< |
if ((fromrp = fdopen(rpd[0], "r")) == NULL || |
| 278 |
< |
(torp = fdopen(rpd[1], "w")) == NULL) { |
| 277 |
> |
if ((fromrp = fdopen(rpd.r, "r")) == NULL || |
| 278 |
> |
(torp = fdopen(rpd.w, "w")) == NULL) { |
| 279 |
|
fprintf(stderr, "%s: cannot open stream to %s\n", |
| 280 |
|
progname, rpargv[0]); |
| 281 |
|
exit(1); |
| 401 |
|
VIEW pview; |
| 402 |
|
int xorg, yorg; |
| 403 |
|
/* compute view parameters */ |
| 404 |
< |
copystruct(&pview, &ourview); |
| 404 |
> |
pview = ourview; |
| 405 |
|
switch (ourview.type) { |
| 406 |
|
case VT_PER: |
| 407 |
|
pview.horiz = 2.*180./PI*atan( |
| 452 |
|
int hr, vr; |
| 453 |
|
register int y; |
| 454 |
|
/* check bounds */ |
| 455 |
< |
if (xpos < 0 | ypos < 0 | xpos >= hmult | ypos >= vmult) { |
| 455 |
> |
if ((xpos < 0) | (ypos < 0) | (xpos >= hmult) | (ypos >= vmult)) { |
| 456 |
|
fprintf(stderr, "%s: requested piece (%d,%d) out of range\n", |
| 457 |
|
progname, xpos, ypos); |
| 458 |
|
exit(cleanup(1)); |
| 460 |
|
/* check header from rpict */ |
| 461 |
|
guard_io(); |
| 462 |
|
getheader(fromrp, NULL, NULL); |
| 463 |
< |
if (!fscnresolu(&hr, &vr, fromrp) || hr != hres | vr != vres) { |
| 463 |
> |
if (!fscnresolu(&hr, &vr, fromrp) || (hr != hres) | (vr != vres)) { |
| 464 |
|
fprintf(stderr, "%s: resolution mismatch from %s\n", |
| 465 |
|
progname, rpargv[0]); |
| 466 |
|
exit(cleanup(1)); |
| 505 |
|
filerr("lock"); |
| 506 |
|
#endif |
| 507 |
|
/* write new piece to file */ |
| 508 |
< |
if (lseek(outfd, fls.l_start, 0) < 0) |
| 508 |
> |
if (lseek(outfd, (off_t)fls.l_start, 0) < 0) |
| 509 |
|
filerr("seek"); |
| 510 |
|
if (hmult == 1) { |
| 511 |
|
if (writebuf(outfd, (char *)pbuf, |
| 517 |
|
hr*sizeof(COLR)) != hr*sizeof(COLR)) |
| 518 |
|
filerr("write"); |
| 519 |
|
if (y < vr-1 && lseek(outfd, |
| 520 |
< |
(long)(hmult-1)*hr*sizeof(COLR), |
| 520 |
> |
(off_t)(hmult-1)*hr*sizeof(COLR), |
| 521 |
|
1) < 0) |
| 522 |
|
filerr("seek"); |
| 523 |
|
} |
| 548 |
|
char *t; |
| 549 |
|
{ |
| 550 |
|
fprintf(stderr, "%s: %s error on file \"%s\": %s\n", |
| 551 |
< |
progname, t, outfile, sys_errlist[errno]); |
| 551 |
> |
progname, t, outfile, strerror(errno)); |
| 552 |
|
_exit(1); |
| 553 |
|
} |
| 554 |
|
|