5 |
|
* Generate sections of a picture. |
6 |
|
*/ |
7 |
|
|
8 |
+ |
|
9 |
+ |
#include <stdio.h> |
10 |
+ |
#include <signal.h> |
11 |
+ |
#include <sys/types.h> |
12 |
+ |
|
13 |
|
#include "platform.h" |
14 |
+ |
#ifndef NON_POSIX /* XXX need abstraction for process management */ |
15 |
+ |
#include <sys/wait.h> |
16 |
+ |
#endif |
17 |
+ |
|
18 |
|
#include "standard.h" |
19 |
+ |
#include "color.h" |
20 |
+ |
#include "view.h" |
21 |
+ |
#include "rtprocess.h" |
22 |
|
|
23 |
|
#ifndef F_SETLKW |
24 |
|
|
25 |
< |
main(argc, argv) |
26 |
< |
int argc; |
27 |
< |
char *argv[]; |
25 |
> |
int |
26 |
> |
main( |
27 |
> |
int argc, |
28 |
> |
char *argv[] |
29 |
> |
) |
30 |
|
{ |
31 |
|
fprintf(stderr, "%s: no NFS lock manager on this machine\n", argv[0]); |
32 |
|
exit(1); |
34 |
|
|
35 |
|
#else |
36 |
|
|
23 |
– |
#include <signal.h> |
24 |
– |
|
25 |
– |
#include "color.h" |
26 |
– |
#include "view.h" |
27 |
– |
#include "rtprocess.h" |
28 |
– |
|
37 |
|
#ifndef NFS |
38 |
|
#define NFS 1 |
39 |
|
#endif |
51 |
|
#define unguard() sigrelse(SIGALRM) |
52 |
|
#endif |
53 |
|
#ifndef guard_io |
54 |
< |
#define guard_io() 0 |
55 |
< |
#define unguard() 0 |
54 |
> |
#define guard_io() |
55 |
> |
#define unguard() |
56 |
|
#endif |
57 |
|
|
58 |
|
extern char *strerror(); |
84 |
|
int gotalrm = 0; |
85 |
|
void onalrm(int i) { gotalrm++; } |
86 |
|
|
87 |
+ |
static void dolock(int fd, int ltyp); |
88 |
+ |
static void init(int ac, char **av); |
89 |
+ |
static int nextpiece(int *xp, int *yp); |
90 |
+ |
static int rvrpiece(int *xp, int *yp); |
91 |
+ |
static int cleanup(int rstat); |
92 |
+ |
static void rpiece(void); |
93 |
+ |
static int putpiece(int xpos, int ypos); |
94 |
+ |
static void filerr(char *t); |
95 |
|
|
96 |
< |
main(argc, argv) |
97 |
< |
int argc; |
98 |
< |
char *argv[]; |
96 |
> |
|
97 |
> |
int |
98 |
> |
main( |
99 |
> |
int argc, |
100 |
> |
char *argv[] |
101 |
> |
) |
102 |
|
{ |
103 |
|
register int i, rval; |
104 |
|
|
207 |
|
} |
208 |
|
|
209 |
|
|
210 |
< |
dolock(fd, ltyp) /* lock or unlock a file */ |
211 |
< |
int fd; |
212 |
< |
int ltyp; |
210 |
> |
static void |
211 |
> |
dolock( /* lock or unlock a file */ |
212 |
> |
int fd, |
213 |
> |
int ltyp |
214 |
> |
) |
215 |
|
{ |
216 |
|
static struct flock fls; /* static so initialized to zeroes */ |
217 |
|
|
224 |
|
} |
225 |
|
|
226 |
|
|
227 |
< |
init(ac, av) /* set up output file and start rpict */ |
228 |
< |
int ac; |
229 |
< |
char **av; |
227 |
> |
static void |
228 |
> |
init( /* set up output file and start rpict */ |
229 |
> |
int ac, |
230 |
> |
char **av |
231 |
> |
) |
232 |
|
{ |
233 |
|
static char hrbuf[16], vrbuf[16]; |
234 |
|
extern char VersionID[]; |
249 |
|
/* compute piece size */ |
250 |
|
hres /= hmult; |
251 |
|
vres /= vmult; |
252 |
+ |
if (hres <= 0 || vres <= 0) { |
253 |
+ |
fprintf(stderr, "%s: illegal resolution/subdivision\n", progname); |
254 |
+ |
exit(1); |
255 |
+ |
} |
256 |
|
normaspect(viewaspect(&ourview)*hmult/vmult, &pixaspect, &hres, &vres); |
257 |
|
sprintf(hrbuf, "%d", hres); |
258 |
|
rpargv[rpargc++] = "-x"; rpargv[rpargc++] = hrbuf; |
322 |
|
} |
323 |
|
|
324 |
|
|
325 |
< |
int |
326 |
< |
nextpiece(xp, yp) /* get next piece assignment */ |
327 |
< |
int *xp, *yp; |
325 |
> |
static int |
326 |
> |
nextpiece( /* get next piece assignment */ |
327 |
> |
int *xp, |
328 |
> |
int *yp |
329 |
> |
) |
330 |
|
{ |
331 |
|
if (gotalrm) /* someone wants us to quit */ |
332 |
|
return(0); |
366 |
|
} |
367 |
|
|
368 |
|
|
369 |
< |
int |
370 |
< |
rvrpiece(xp, yp) /* check for recoverable pieces */ |
371 |
< |
register int *xp, *yp; |
369 |
> |
static int |
370 |
> |
rvrpiece( /* check for recoverable pieces */ |
371 |
> |
register int *xp, |
372 |
> |
register int *yp |
373 |
> |
) |
374 |
|
{ |
375 |
|
static char *pdone = NULL; /* which pieces are done */ |
376 |
|
static long readpos = -1; /* how far we've read */ |
412 |
|
} |
413 |
|
|
414 |
|
|
415 |
< |
int |
416 |
< |
cleanup(rstat) /* close rpict process and clean up */ |
417 |
< |
int rstat; |
415 |
> |
static int |
416 |
> |
cleanup( /* close rpict process and clean up */ |
417 |
> |
int rstat |
418 |
> |
) |
419 |
|
{ |
420 |
|
int status; |
421 |
|
|
429 |
|
} |
430 |
|
|
431 |
|
|
432 |
< |
rpiece() /* render picture piece by piece */ |
432 |
> |
static void |
433 |
> |
rpiece(void) /* render picture piece by piece */ |
434 |
|
{ |
435 |
|
VIEW pview; |
436 |
|
int xorg, yorg; |
438 |
|
pview = ourview; |
439 |
|
switch (ourview.type) { |
440 |
|
case VT_PER: |
441 |
< |
pview.horiz = 2.*180./PI*atan( |
442 |
< |
tan(PI/180./2.*ourview.horiz)/hmult ); |
443 |
< |
pview.vert = 2.*180./PI*atan( |
444 |
< |
tan(PI/180./2.*ourview.vert)/vmult ); |
441 |
> |
pview.horiz = (2.*180./PI)*atan( |
442 |
> |
tan((PI/180./2.)*ourview.horiz)/hmult ); |
443 |
> |
pview.vert = (2.*180./PI)*atan( |
444 |
> |
tan((PI/180./2.)*ourview.vert)/vmult ); |
445 |
|
break; |
446 |
|
case VT_PAR: |
447 |
|
case VT_ANG: |
450 |
|
break; |
451 |
|
case VT_CYL: |
452 |
|
pview.horiz = ourview.horiz / hmult; |
453 |
< |
pview.vert = 2.*180./PI*atan( |
454 |
< |
tan(PI/180./2.*ourview.vert)/vmult ); |
453 |
> |
pview.vert = (2.*180./PI)*atan( |
454 |
> |
tan((PI/180./2.)*ourview.vert)/vmult ); |
455 |
|
break; |
456 |
|
case VT_HEM: |
457 |
< |
pview.horiz = 2.*180./PI*asin( |
458 |
< |
sin(PI/180./2.*ourview.horiz)/hmult ); |
459 |
< |
pview.vert = 2.*180./PI*asin( |
460 |
< |
sin(PI/180./2.*ourview.vert)/vmult ); |
457 |
> |
pview.horiz = (2.*180./PI)*asin( |
458 |
> |
sin((PI/180./2.)*ourview.horiz)/hmult ); |
459 |
> |
pview.vert = (2.*180./PI)*asin( |
460 |
> |
sin((PI/180./2.)*ourview.vert)/vmult ); |
461 |
|
break; |
462 |
+ |
case VT_PLS: |
463 |
+ |
pview.horiz = sin((PI/180./2.)*ourview.horiz) / |
464 |
+ |
(1.0 + cos((PI/180./2.)*ourview.horiz)) / hmult; |
465 |
+ |
pview.horiz *= pview.horiz; |
466 |
+ |
pview.horiz = (2.*180./PI)*acos((1. - pview.horiz) / |
467 |
+ |
(1. + pview.horiz)); |
468 |
+ |
pview.vert = sin((PI/180./2.)*ourview.vert) / |
469 |
+ |
(1.0 + cos((PI/180./2.)*ourview.vert)) / vmult; |
470 |
+ |
pview.vert *= pview.vert; |
471 |
+ |
pview.vert = (2.*180./PI)*acos((1. - pview.vert) / |
472 |
+ |
(1. + pview.vert)); |
473 |
+ |
break; |
474 |
|
default: |
475 |
|
fprintf(stderr, "%s: unknown view type '-vt%c'\n", |
476 |
|
progname, ourview.type); |
489 |
|
} |
490 |
|
|
491 |
|
|
492 |
< |
int |
493 |
< |
putpiece(xpos, ypos) /* get next piece from rpict */ |
494 |
< |
int xpos, ypos; |
492 |
> |
static int |
493 |
> |
putpiece( /* get next piece from rpict */ |
494 |
> |
int xpos, |
495 |
> |
int ypos |
496 |
> |
) |
497 |
|
{ |
498 |
|
struct flock fls; |
499 |
|
int pid, status; |
592 |
|
} |
593 |
|
|
594 |
|
|
595 |
< |
filerr(t) /* report file error and exit */ |
596 |
< |
char *t; |
595 |
> |
static void |
596 |
> |
filerr( /* report file error and exit */ |
597 |
> |
char *t |
598 |
> |
) |
599 |
|
{ |
600 |
|
fprintf(stderr, "%s: %s error on file \"%s\": %s\n", |
601 |
|
progname, t, outfile, strerror(errno)); |