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