--- ray/src/gen/replmarks.c 2003/02/22 02:07:24 2.5 +++ ray/src/gen/replmarks.c 2004/01/02 17:11:40 2.10 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: replmarks.c,v 2.5 2003/02/22 02:07:24 greg Exp $"; +static const char RCSid[] = "$Id"; #endif /* * Replace markers in Radiance scene description with objects or instances. @@ -7,11 +7,14 @@ static const char RCSid[] = "$Id: replmarks.c,v 2.5 20 * Created: 17 Feb 1991 Greg Ward */ -#include #include #include #include +#include +#include "platform.h" +#include "rtio.h" +#include "rtprocess.h" #include "fvect.h" #ifdef M_PI @@ -43,10 +46,20 @@ int expand; /* expand commands? */ char *progname; +static void convert(char *name, FILE *fin); +static void cvcomm(char *fname, FILE *fin); +static void cvobject(char *fname, FILE *fin); +static void replace(char *fname, struct mrkr *m, char *mark, FILE *fin); +static int edgecmp(const void *e1, const void *e2); +static int buildxf(char *xf, double markscale, FILE *fin); +static int addrot(char *xf, FVECT xp, FVECT yp, FVECT zp); -main(argc, argv) -int argc; -char *argv[]; + +int +main( + int argc, + char *argv[] +) { FILE *fp; int i, j; @@ -106,18 +119,20 @@ char *argv[]; convert(argv[i], fp); fclose(fp); } - exit(0); + return 0; userr: fprintf(stderr, "Usage: %s [-e][-s size][-m modout] {-x objfile|-i octree} modname .. [file ..]\n", progname); - exit(1); + return 1; } -convert(name, fin) /* replace marks in a stream */ -char *name; -register FILE *fin; +void +convert( /* replace marks in a stream */ + char *name, + register FILE *fin +) { register int c; @@ -142,11 +157,13 @@ register FILE *fin; } -cvcomm(fname, fin) /* convert a command */ -char *fname; -FILE *fin; +void +cvcomm( /* convert a command */ + char *fname, + FILE *fin +) { - FILE *pin, *popen(); + FILE *pin; char buf[512], *fgetline(); fgetline(buf, sizeof(buf), fin); @@ -164,10 +181,13 @@ FILE *fin; } -cvobject(fname, fin) /* convert an object */ -char *fname; -FILE *fin; +void +cvobject( /* convert an object */ + char *fname, + FILE *fin +) { + extern char *fgetword(); char buf[128], typ[16], nam[128]; int i, n; register int j; @@ -208,18 +228,20 @@ readerr: } -replace(fname, m, mark, fin) /* replace marker */ -char *fname; -register struct mrkr *m; -char *mark; -FILE *fin; +void +replace( /* replace marker */ + char *fname, + register struct mrkr *m, + char *mark, + FILE *fin +) { int n; char buf[256]; buf[0] = '\0'; /* bug fix thanks to schorsch */ if (m->doxform) { - sprintf(buf, "xform -e -n %s", mark); + sprintf(buf, "xform -n %s", mark); if (m->modout != NULL) sprintf(buf+strlen(buf), " -m %s", m->modout); if (buildxf(buf+strlen(buf), m->mscale, fin) < 0) @@ -245,22 +267,26 @@ badxf: } -edgecmp(e1, e2) /* compare two edges, descending order */ -EDGE *e1, *e2; +int +edgecmp( /* compare two edges, descending order */ + const void *e1, + const void *e2 +) { - if (e1->len2 > e2->len2) + if (((EDGE*)e1)->len2 > ((EDGE*)e2)->len2) return(-1); - if (e1->len2 < e2->len2) + if (((EDGE*)e1)->len2 < ((EDGE*)e2)->len2) return(1); return(0); } int -buildxf(xf, markscale, fin) /* build transform for marker */ -register char *xf; -double markscale; -FILE *fin; +buildxf( /* build transform for marker */ + register char *xf, + double markscale, + FILE *fin +) { static FVECT vlist[MAXVERT]; static EDGE elist[MAXVERT]; @@ -338,9 +364,13 @@ FILE *fin; } -addrot(xf, xp, yp, zp) /* compute rotation (x,y,z) => (xp,yp,zp) */ -register char *xf; -FVECT xp, yp, zp; +int +addrot( /* compute rotation (x,y,z) => (xp,yp,zp) */ + register char *xf, + FVECT xp, + FVECT yp, + FVECT zp +) { int n; double theta;