--- ray/src/util/xglaresrc.c 2003/11/10 16:52:24 2.7 +++ ray/src/util/xglaresrc.c 2020/05/14 20:58:03 2.12 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: xglaresrc.c,v 2.7 2003/11/10 16:52:24 greg Exp $"; +static const char RCSid[] = "$Id: xglaresrc.c,v 2.12 2020/05/14 20:58:03 greg Exp $"; #endif /* * Circle sources in a displayed image. @@ -8,12 +8,14 @@ static const char RCSid[] = "$Id: xglaresrc.c,v 2.7 20 */ #include "standard.h" -#include "view.h" -#include "paths.h" + +#include #include #include #include +#include "view.h" + #define XIM "ximage" #define NSEG 30 /* number of segments per circle */ @@ -35,10 +37,17 @@ Display *theDisplay = NULL; /* connection to server * GC vecGC, strGC; Window gwind; +static void init(char *pname, char *wname); +static void circle_sources(FILE *fp); +static void circle(FVECT dir, double dom); +static void value(FVECT dir, double v); -main(argc, argv) -int argc; -char *argv[]; + +int +main( + int argc, + char *argv[] +) { char *windowname = NULL; FILE *fp; @@ -77,8 +86,11 @@ char *argv[]; } -init(pname, wname) /* get view and find window */ -char *pname, *wname; +static void +init( /* get view and find window */ + char *pname, + char *wname +) { extern Window xfindwind(); XWindowAttributes wa; @@ -117,7 +129,7 @@ char *pname, *wname; exit(2); } /* start ximage */ - if (vfork() == 0) { + if (fork() == 0) { execlp(XIM, XIM, "-c", "256", pname, 0); perror(XIM); fprintf(stderr, "%s: cannot start %s\n", @@ -177,8 +189,10 @@ char *pname, *wname; } -circle_sources(fp) /* circle sources listed in fp */ -FILE *fp; +static void +circle_sources( /* circle sources listed in fp */ + FILE *fp +) { char linbuf[256]; int reading = 0; @@ -191,9 +205,10 @@ FILE *fp; XFlush(theDisplay); return; } - if (sscanf(linbuf, "%lf %lf %lf %lf %lf", - &dir[0], &dir[1], &dir[2], - &dom, &lum) != 5) + if (sscanf(linbuf, FVFORMAT, + &dir[0], &dir[1], &dir[2]) != 3 || + sscanf(sskip2(linbuf, 3), "%lf %lf", + &dom, &lum) != 2) break; circle(dir, dom); value(dir, lum); @@ -205,9 +220,11 @@ FILE *fp; } -circle(dir, dom) /* indicate a solid angle on image */ -FVECT dir; -double dom; +static void +circle( /* indicate a solid angle on image */ + FVECT dir, + double dom +) { FVECT start, cur; XPoint pt[NSEG+1]; @@ -224,8 +241,7 @@ double dom; cur[0] += ourview.vp[0]; cur[1] += ourview.vp[1]; cur[2] += ourview.vp[2]; - viewloc(pp, &ourview, cur); - if (pp[2] <= 0.0) + if (viewloc(pp, &ourview, cur) != VL_GOOD) goto fail; loc2pix(ip, &pres, pp[0], pp[1]); pt[i].x = ip[0]; @@ -239,9 +255,11 @@ fail: } -value(dir, v) /* print value on image */ -FVECT dir; -double v; +static void +value( /* print value on image */ + FVECT dir, + double v +) { FVECT pos; FVECT pp; @@ -251,8 +269,7 @@ double v; pos[0] = ourview.vp[0] + dir[0]; pos[1] = ourview.vp[1] + dir[1]; pos[2] = ourview.vp[2] + dir[2]; - viewloc(pp, &ourview, pos); - if (pp[2] <= 0.0) + if (viewloc(pp, &ourview, pos) != VL_GOOD) return; loc2pix(ip, &pres, pp[0], pp[1]); sprintf(buf, "%.0f", v);