--- ray/src/hd/genrhgrid.c 2003/02/22 02:07:24 3.2 +++ ray/src/hd/genrhgrid.c 2019/10/21 18:19:32 3.10 @@ -1,10 +1,14 @@ #ifndef lint -static const char RCSid[] = "$Id: genrhgrid.c,v 3.2 2003/02/22 02:07:24 greg Exp $"; +static const char RCSid[] = "$Id: genrhgrid.c,v 3.10 2019/10/21 18:19:32 greg Exp $"; #endif /* * Generate renderable grids from a holodeck file */ +#include + +#include "platform.h" +#include "resolu.h" #include "holo.h" char *progname; /* global argv[0] */ @@ -12,15 +16,21 @@ char *progname; /* global argv[0] */ char *mat, *name; /* material and object id */ double rad; /* grid line radius */ +static void gridsect(char *fname, int sect); +static void putgrid(HOLO *hp); +static void putline(FVECT wp[2]); -main(argc, argv) -int argc; -char *argv[]; + +int +main( + int argc, + char *argv[] +) { int sect; progname = argv[0]; - if (argc < 5 | argc > 6) + if ((argc < 5) | (argc > 6)) goto userr; mat = argv[1]; name = argv[2]; @@ -37,18 +47,19 @@ userr: } -gridsect(fname, sect) /* get specified section(s) and print grids */ -char *fname; -int sect; +void +gridsect( /* get specified section(s) and print grids */ + char *fname, + int sect +) { - extern long ftell(); FILE *fp; HOLO hdsect; int fd; - int4 nextloc; + int32 nextloc; int n; /* open holodeck file */ - if ((fp = fopen(fname, "r")) == NULL) { + if ((fp = fopen(fname, "rb")) == NULL) { sprintf(errmsg, "cannot open \"%s\"", fname); error(SYSTEM, errmsg); } @@ -61,9 +72,9 @@ int sect; nextloc = ftell(fp); /* get stdio position */ fclose(fp); /* done with stdio */ for (n = 0; nextloc > 0L; n++) { /* get the section(s) */ - lseek(fd, (off_t)nextloc, 0); + lseek(fd, (off_t)nextloc, SEEK_SET); read(fd, (char *)&nextloc, sizeof(nextloc)); - if (sect < 0 | n == sect) { + if ((sect < 0) | (n == sect)) { read(fd, (char *)&hdsect, sizeof(HDGRID)); hdcompgrid(&hdsect); putgrid(&hdsect); /* print grid */ @@ -72,10 +83,12 @@ int sect; } -putgrid(hp) /* run through holodeck section grid lines */ -register HOLO *hp; +void +putgrid( /* run through holodeck section grid lines */ + HOLO *hp +) { - register int w, i; + int w, i; int g0, g1; FVECT wp[2], mov; double d; @@ -120,8 +133,10 @@ register HOLO *hp; } -putline(wp) /* put out a line */ -register FVECT wp[2]; +void +putline( /* put out a line */ + FVECT wp[2] +) { static int cnt = 0;