| 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 |
|
*/ |
| 22 |
|
#include <signal.h> |
| 23 |
|
#include "color.h" |
| 24 |
|
#include "view.h" |
| 28 |
– |
#include "resolu.h" |
| 25 |
|
|
| 26 |
|
#ifndef NFS |
| 27 |
|
#define NFS 1 |
| 43 |
|
#define guard_io() 0 |
| 44 |
|
#define unguard() 0 |
| 45 |
|
#endif |
| 46 |
+ |
|
| 47 |
+ |
extern char *strerror(); |
| 48 |
+ |
|
| 49 |
|
/* rpict command */ |
| 50 |
|
char *rpargv[128] = {"rpict", "-S", "1"}; |
| 51 |
|
int rpargc = 3; |
| 71 |
|
unsigned timelim = 0; |
| 72 |
|
int rvrlim = -1; |
| 73 |
|
|
| 75 |
– |
extern long lseek(), ftell(); |
| 76 |
– |
|
| 74 |
|
int gotalrm = 0; |
| 75 |
|
int onalrm() { gotalrm++; } |
| 76 |
|
|
| 84 |
|
progname = argv[0]; |
| 85 |
|
for (i = 1; i < argc; i++) { |
| 86 |
|
/* expand arguments */ |
| 87 |
< |
while (rval = expandarg(&argc, &argv, i)) |
| 88 |
< |
if (rval < 0) { |
| 89 |
< |
fprintf(stderr, "%s: cannot expand '%s'", |
| 90 |
< |
argv[0], argv[i]); |
| 91 |
< |
exit(1); |
| 92 |
< |
} |
| 87 |
> |
while ((rval = expandarg(&argc, &argv, i)) > 0) |
| 88 |
> |
; |
| 89 |
> |
if (rval < 0) { |
| 90 |
> |
fprintf(stderr, "%s: cannot expand '%s'", |
| 91 |
> |
argv[0], argv[i]); |
| 92 |
> |
exit(1); |
| 93 |
> |
} |
| 94 |
|
if (argv[i][0] == '-') |
| 95 |
|
switch (argv[i][1]) { |
| 96 |
|
case 'v': |
| 117 |
|
case 'p': /* pixel aspect ratio? */ |
| 118 |
|
if (argv[i][2] != 'a' || argv[i][3]) |
| 119 |
|
break; |
| 120 |
< |
pixaspect = atof(argv[i+1]); |
| 120 |
> |
pixaspect = atof(argv[++i]); |
| 121 |
|
continue; |
| 122 |
|
case 'T': /* time limit (hours) */ |
| 123 |
|
if (argv[i][2]) |
| 191 |
|
int ltyp; |
| 192 |
|
{ |
| 193 |
|
static struct flock fls; /* static so initialized to zeroes */ |
| 196 |
– |
extern char *sys_errlist[]; |
| 194 |
|
|
| 195 |
|
fls.l_type = ltyp; |
| 196 |
|
if (fcntl(fd, F_SETLKW, &fls) < 0) { |
| 197 |
|
fprintf(stderr, "%s: cannot lock/unlock file: %s\n", |
| 198 |
< |
progname, sys_errlist[errno]); |
| 198 |
> |
progname, strerror(errno)); |
| 199 |
|
exit(1); |
| 200 |
|
} |
| 201 |
|
} |
| 412 |
|
pview.horiz = ourview.horiz / hmult; |
| 413 |
|
pview.vert = ourview.vert / vmult; |
| 414 |
|
break; |
| 415 |
+ |
case VT_CYL: |
| 416 |
+ |
pview.horiz = ourview.horiz / hmult; |
| 417 |
+ |
pview.vert = 2.*180./PI*atan( |
| 418 |
+ |
tan(PI/180./2.*ourview.vert)/vmult ); |
| 419 |
+ |
break; |
| 420 |
|
case VT_HEM: |
| 421 |
|
pview.horiz = 2.*180./PI*asin( |
| 422 |
|
sin(PI/180./2.*ourview.horiz)/hmult ); |
| 430 |
|
} |
| 431 |
|
/* render each piece */ |
| 432 |
|
while (nextpiece(&xorg, &yorg)) { |
| 433 |
< |
pview.hoff = ourview.hoff + xorg - 0.5*(hmult-1); |
| 434 |
< |
pview.voff = ourview.voff + yorg - 0.5*(vmult-1); |
| 433 |
> |
pview.hoff = ourview.hoff*hmult + xorg - 0.5*(hmult-1); |
| 434 |
> |
pview.voff = ourview.voff*vmult + yorg - 0.5*(vmult-1); |
| 435 |
|
fputs(VIEWSTR, torp); |
| 436 |
|
fprintview(&pview, torp); |
| 437 |
|
putc('\n', torp); |
| 503 |
|
filerr("lock"); |
| 504 |
|
#endif |
| 505 |
|
/* write new piece to file */ |
| 506 |
< |
if (lseek(outfd, fls.l_start, 0) == -1) |
| 506 |
> |
if (lseek(outfd, (off_t)fls.l_start, 0) < 0) |
| 507 |
|
filerr("seek"); |
| 508 |
|
if (hmult == 1) { |
| 509 |
|
if (writebuf(outfd, (char *)pbuf, |
| 515 |
|
hr*sizeof(COLR)) != hr*sizeof(COLR)) |
| 516 |
|
filerr("write"); |
| 517 |
|
if (y < vr-1 && lseek(outfd, |
| 518 |
< |
(long)(hmult-1)*hr*sizeof(COLR), |
| 519 |
< |
1) == -1) |
| 518 |
> |
(off_t)(hmult-1)*hr*sizeof(COLR), |
| 519 |
> |
1) < 0) |
| 520 |
|
filerr("seek"); |
| 521 |
|
} |
| 522 |
|
#if NFS |
| 524 |
|
if (fcntl(outfd, F_SETLKW, &fls) < 0) |
| 525 |
|
filerr("lock"); |
| 526 |
|
#endif |
| 527 |
+ |
if (verbose) { /* notify caller */ |
| 528 |
+ |
printf("%d %d done\n", xpos, ypos); |
| 529 |
+ |
fflush(stdout); |
| 530 |
+ |
} |
| 531 |
|
if (syncfp != NULL) { /* record what's been done */ |
| 532 |
|
sflock(F_WRLCK); |
| 533 |
|
fseek(syncfp, 0L, 2); /* append index */ |
| 536 |
|
/*** Unlock not necessary, since |
| 537 |
|
sflock(F_UNLCK); _exit() or nextpiece() is next ***/ |
| 538 |
|
} |
| 533 |
– |
if (verbose) { /* notify caller */ |
| 534 |
– |
printf("%d %d done\n", xpos, ypos); |
| 535 |
– |
fflush(stdout); |
| 536 |
– |
} |
| 539 |
|
if (pid == -1) /* didn't fork or fork failed */ |
| 540 |
|
return(0); |
| 541 |
|
_exit(0); /* else exit child process (releasing locks) */ |
| 545 |
|
filerr(t) /* report file error and exit */ |
| 546 |
|
char *t; |
| 547 |
|
{ |
| 546 |
– |
extern char *sys_errlist[]; |
| 547 |
– |
|
| 548 |
|
fprintf(stderr, "%s: %s error on file \"%s\": %s\n", |
| 549 |
< |
progname, t, outfile, sys_errlist[errno]); |
| 549 |
> |
progname, t, outfile, strerror(errno)); |
| 550 |
|
_exit(1); |
| 551 |
|
} |
| 552 |
|
|