--- ray/src/hd/genrhgrid.c 2003/07/27 22:12:02 3.5 +++ 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.5 2003/07/27 22:12:02 schorsch 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,10 +16,16 @@ 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; @@ -37,9 +47,11 @@ 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 +) { FILE *fp; HOLO hdsect; @@ -47,7 +59,7 @@ int sect; 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); } @@ -60,7 +72,7 @@ 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)) { read(fd, (char *)&hdsect, sizeof(HDGRID)); @@ -71,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; @@ -119,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;