ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/x11image.c
(Generate patch)

Comparing ray/src/px/x11image.c (file contents):
Revision 2.29 by greg, Wed Oct 27 13:03:18 1993 UTC vs.
Revision 2.32 by greg, Thu Oct 28 11:39:59 1993 UTC

# Line 119 | Line 119 | extern long  ftell();
119   Display  *thedisplay;
120   Atom  closedownAtom, wmProtocolsAtom;
121  
122 < int  noop() {}
122 > int  sigrecv;
123  
124 + int  onsig() { sigrecv++; }
125  
126 +
127   main(argc, argv)
128   int  argc;
129   char  *argv[];
# Line 179 | Line 181 | char  *argv[];
181          if (i > argc)
182                  goto userr;
183          while (i < argc-1) {
184 +                sigrecv = 0;
185 +                signal(SIGCONT, onsig);
186                  if ((pid=fork()) == 0) {        /* a child for each picture */
187                          parent = -1;
188                          break;
# Line 186 | Line 190 | char  *argv[];
190                  if (pid < 0)
191                          quiterr("fork failed");
192                  parent++;
193 <                signal(SIGCONT, noop);
194 <                pause();                /* wait for wake-up call */
193 >                while (!sigrecv)
194 >                        pause();        /* wait for wake-up call */
195                  i++;
196          }
197          if (i < argc) {                 /* open picture file */
# Line 213 | Line 217 | char  *argv[];
217  
218          init(argc, argv);                       /* get file and open window */
219  
220 <        if (parent < 0)
220 >        if (parent < 0) {
221                  kill(getppid(), SIGCONT);       /* signal parent if child */
222 <
222 >                sigrecv--;
223 >        }
224          for ( ; ; )
225                  getevent();             /* main loop */
226   userr:
# Line 311 | Line 316 | char **argv;
316                  quiterr("cannot create window");
317          width = xmax;
318          height = ymax;
319 <        xgcv.foreground = ourblack;
315 <        xgcv.background = ourwhite;
319 >        /* prepare graphics drawing context */
320          if ((xgcv.font = XLoadFont(thedisplay, FONTNAME)) == 0)
321                  quiterr("cannot get font");
322 +        xgcv.foreground = ourblack;
323 +        xgcv.background = ourwhite;
324          ourgc = XCreateGC(thedisplay, wind, GCForeground|GCBackground|
325                          GCFont, &xgcv);
326          xgcv.function = GXinvert;
# Line 350 | Line 356 | char **argv;
356   quiterr(err)            /* print message and exit */
357   char  *err;
358   {
359 <        if (err != NULL)
359 >        register int  es;
360 >        int  cs;
361 >
362 >        if (es = err != NULL)
363                  fprintf(stderr, "%s: %s: %s\n", progname,
364                                  fname==NULL?"<stdin>":fname, err);
365 <        if (wind) {
365 >        if (parent > 0 & wind != 0) {
366                  XDestroyWindow(thedisplay, wind);
367                  XFlush(thedisplay);
368 <        }
369 <        while (parent > 0 && wait(0) != -1)     /* wait for any children */
368 >        } else if (parent < 0 & sigrecv == 0)
369 >                kill(getppid(), SIGCONT);
370 >        while (parent > 0 && wait(&cs) != -1) { /* wait for any children */
371 >                if (es == 0)
372 >                        es = cs>>8 & 0xff;
373                  parent--;
374 <        exit(err != NULL);
374 >        }
375 >        exit(es);
376   }
377  
378  
# Line 970 | Line 983 | getgrey()                      /* get greyscale data */
983   getmapped()                     /* get color-mapped data */
984   {
985          int     y;
986 +                                        /* make sure we can do it first */
987 +        if (fname == NULL)
988 +                quiterr("cannot map colors from standard input");
989                                          /* set gamma correction */
990          setcolrgam(gamcor);
991                                          /* make histogram */
992          new_histo();
993          for (y = 0; y < ymax; y++) {
994                  if (getscan(y) < 0)
995 <                        quiterr("seek error in getmapped");
995 >                        break;
996                  add2icon(y, scanline);
997                  if (scale)
998                          shiftcolrs(scanline, xmax, scale);
# Line 987 | Line 1003 | getmapped()                    /* get color-mapped data */
1003          if (!new_clrtab(maxcolors))
1004                  quiterr("cannot create color map");
1005          for (y = 0; y < ymax; y++) {
1006 <                if (getscan(y) < 0)
991 <                        quiterr("seek error in getmapped");
1006 >                getscan(y);
1007                  if (scale)
1008                          shiftcolrs(scanline, xmax, scale);
1009                  colrs_gambs(scanline, xmax);
# Line 1031 | Line 1046 | double sf;
1046   getscan(y)
1047   int  y;
1048   {
1049 +        static int  trunced = -1;               /* truncated file? */
1050 + skipit:
1051 +        if (trunced >= 0 && y >= trunced) {
1052 +                bzero(scanline, xmax*sizeof(COLR));
1053 +                return(-1);
1054 +        }
1055          if (y != cury) {
1056                  if (scanpos == NULL || scanpos[y] == -1)
1057                          return(-1);
# Line 1040 | Line 1061 | int  y;
1061          } else if (scanpos != NULL && scanpos[y] == -1)
1062                  scanpos[y] = ftell(fin);
1063  
1064 <        if (freadcolrs(scanline, xmax, fin) < 0)
1065 <                quiterr("read error");
1066 <
1064 >        if (freadcolrs(scanline, xmax, fin) < 0) {
1065 >                fprintf(stderr, "%s: %s: unfinished picture\n",
1066 >                                progname, fname==NULL?"<stdin>":fname);
1067 >                trunced = y;
1068 >                goto skipit;
1069 >        }
1070          cury++;
1071          return(0);
1072   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines