5 |
|
* Generate sections of a picture. |
6 |
|
*/ |
7 |
|
|
8 |
– |
#include "standard.h" |
8 |
|
|
9 |
+ |
#include <stdio.h> |
10 |
+ |
#include <signal.h> |
11 |
+ |
#include <sys/types.h> |
12 |
+ |
#include <sys/wait.h> |
13 |
+ |
|
14 |
+ |
#include "platform.h" |
15 |
+ |
#include "rtio.h" |
16 |
+ |
#include "rtmisc.h" |
17 |
+ |
#include "color.h" |
18 |
+ |
#include "view.h" |
19 |
+ |
#include "rtprocess.h" |
20 |
+ |
|
21 |
|
#ifndef F_SETLKW |
22 |
|
|
23 |
< |
main(argc, argv) |
24 |
< |
int argc; |
25 |
< |
char *argv[]; |
23 |
> |
int |
24 |
> |
main( |
25 |
> |
int argc, |
26 |
> |
char *argv[] |
27 |
> |
) |
28 |
|
{ |
29 |
|
fprintf(stderr, "%s: no NFS lock manager on this machine\n", argv[0]); |
30 |
|
exit(1); |
32 |
|
|
33 |
|
#else |
34 |
|
|
22 |
– |
#include <signal.h> |
23 |
– |
|
24 |
– |
#include "color.h" |
25 |
– |
#include "view.h" |
26 |
– |
#include "rtprocess.h" |
27 |
– |
|
35 |
|
#ifndef NFS |
36 |
|
#define NFS 1 |
37 |
|
#endif |
49 |
|
#define unguard() sigrelse(SIGALRM) |
50 |
|
#endif |
51 |
|
#ifndef guard_io |
52 |
< |
#define guard_io() 0 |
53 |
< |
#define unguard() 0 |
52 |
> |
#define guard_io() |
53 |
> |
#define unguard() |
54 |
|
#endif |
55 |
|
|
56 |
|
extern char *strerror(); |
82 |
|
int gotalrm = 0; |
83 |
|
void onalrm(int i) { gotalrm++; } |
84 |
|
|
85 |
+ |
static void dolock(int fd, int ltyp); |
86 |
+ |
static void init(int ac, char **av); |
87 |
+ |
static int nextpiece(int *xp, int *yp); |
88 |
+ |
static int rvrpiece(int *xp, int *yp); |
89 |
+ |
static int cleanup(int rstat); |
90 |
+ |
static void rpiece(void); |
91 |
+ |
static int putpiece(int xpos, int ypos); |
92 |
+ |
static void filerr(char *t); |
93 |
|
|
94 |
< |
main(argc, argv) |
95 |
< |
int argc; |
96 |
< |
char *argv[]; |
94 |
> |
|
95 |
> |
int |
96 |
> |
main( |
97 |
> |
int argc, |
98 |
> |
char *argv[] |
99 |
> |
) |
100 |
|
{ |
101 |
|
register int i, rval; |
102 |
|
|
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
< |
dolock(fd, ltyp) /* lock or unlock a file */ |
209 |
< |
int fd; |
210 |
< |
int ltyp; |
208 |
> |
static void |
209 |
> |
dolock( /* lock or unlock a file */ |
210 |
> |
int fd, |
211 |
> |
int ltyp |
212 |
> |
) |
213 |
|
{ |
214 |
|
static struct flock fls; /* static so initialized to zeroes */ |
215 |
|
|
222 |
|
} |
223 |
|
|
224 |
|
|
225 |
< |
init(ac, av) /* set up output file and start rpict */ |
226 |
< |
int ac; |
227 |
< |
char **av; |
225 |
> |
static void |
226 |
> |
init( /* set up output file and start rpict */ |
227 |
> |
int ac, |
228 |
> |
char **av |
229 |
> |
) |
230 |
|
{ |
231 |
|
static char hrbuf[16], vrbuf[16]; |
232 |
|
extern char VersionID[]; |
316 |
|
} |
317 |
|
|
318 |
|
|
319 |
< |
int |
320 |
< |
nextpiece(xp, yp) /* get next piece assignment */ |
321 |
< |
int *xp, *yp; |
319 |
> |
static int |
320 |
> |
nextpiece( /* get next piece assignment */ |
321 |
> |
int *xp, |
322 |
> |
int *yp |
323 |
> |
) |
324 |
|
{ |
325 |
|
if (gotalrm) /* someone wants us to quit */ |
326 |
|
return(0); |
360 |
|
} |
361 |
|
|
362 |
|
|
363 |
< |
int |
364 |
< |
rvrpiece(xp, yp) /* check for recoverable pieces */ |
365 |
< |
register int *xp, *yp; |
363 |
> |
static int |
364 |
> |
rvrpiece( /* check for recoverable pieces */ |
365 |
> |
register int *xp, |
366 |
> |
register int *yp |
367 |
> |
) |
368 |
|
{ |
369 |
|
static char *pdone = NULL; /* which pieces are done */ |
370 |
|
static long readpos = -1; /* how far we've read */ |
406 |
|
} |
407 |
|
|
408 |
|
|
409 |
< |
int |
410 |
< |
cleanup(rstat) /* close rpict process and clean up */ |
411 |
< |
int rstat; |
409 |
> |
static int |
410 |
> |
cleanup( /* close rpict process and clean up */ |
411 |
> |
int rstat |
412 |
> |
) |
413 |
|
{ |
414 |
|
int status; |
415 |
|
|
423 |
|
} |
424 |
|
|
425 |
|
|
426 |
< |
rpiece() /* render picture piece by piece */ |
426 |
> |
static void |
427 |
> |
rpiece(void) /* render picture piece by piece */ |
428 |
|
{ |
429 |
|
VIEW pview; |
430 |
|
int xorg, yorg; |
471 |
|
} |
472 |
|
|
473 |
|
|
474 |
< |
int |
475 |
< |
putpiece(xpos, ypos) /* get next piece from rpict */ |
476 |
< |
int xpos, ypos; |
474 |
> |
static int |
475 |
> |
putpiece( /* get next piece from rpict */ |
476 |
> |
int xpos, |
477 |
> |
int ypos |
478 |
> |
) |
479 |
|
{ |
480 |
|
struct flock fls; |
481 |
|
int pid, status; |
535 |
|
filerr("lock"); |
536 |
|
#endif |
537 |
|
/* write new piece to file */ |
538 |
< |
if (lseek(outfd, (off_t)fls.l_start, 0) < 0) |
538 |
> |
if (lseek(outfd, (off_t)fls.l_start, SEEK_SET) < 0) |
539 |
|
filerr("seek"); |
540 |
|
if (hmult == 1) { |
541 |
|
if (writebuf(outfd, (char *)pbuf, |
548 |
|
filerr("write"); |
549 |
|
if (y < vr-1 && lseek(outfd, |
550 |
|
(off_t)(hmult-1)*hr*sizeof(COLR), |
551 |
< |
1) < 0) |
551 |
> |
SEEK_CUR) < 0) |
552 |
|
filerr("seek"); |
553 |
|
} |
554 |
|
#if NFS |
574 |
|
} |
575 |
|
|
576 |
|
|
577 |
< |
filerr(t) /* report file error and exit */ |
578 |
< |
char *t; |
577 |
> |
static void |
578 |
> |
filerr( /* report file error and exit */ |
579 |
> |
char *t |
580 |
> |
) |
581 |
|
{ |
582 |
|
fprintf(stderr, "%s: %s error on file \"%s\": %s\n", |
583 |
|
progname, t, outfile, strerror(errno)); |