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

Comparing ray/src/meta/igraph.c (file contents):
Revision 1.2 by schorsch, Mon Oct 27 10:28:59 2003 UTC vs.
Revision 1.3 by schorsch, Fri Nov 14 00:14:40 2003 UTC

# Line 10 | Line 10 | static const char      RCSid[] = "$Id$";
10   */
11  
12   #include  <stdio.h>
13
13   #include  <ctype.h>
15
14   #include  <setjmp.h>
15  
16   #include  "rtprocess.h"
17 + #include  "rterror.h"
18   #include  "mgvars.h"
19  
20   typedef struct {
# Line 68 | Line 67 | static jmp_buf  env;           /* setjmp buffer */
67  
68   static char  curfile[64] = "temp.plt";  /* current file name */
69  
70 < char  *getfile(), *gets(), *strcpy();
70 > static void mainmenu(void);
71 > static void uwait(void);
72 > static void gcompute(void);
73 > static void setvars(int  nvar, VARIABLE  vars[]);
74 > static void plotout(void);
75 > static void settype(void);
76 > static char  *getfile(void);
77  
78 <
78 > int
79   main(argc, argv)
80   int  argc;
81   char  *argv[];
# Line 93 | Line 98 | char  *argv[];
98          quit(0);
99   }
100  
101 <
101 > extern void
102   eputs(msg)                              /* print error message */
103   char  *msg;
104   {
105          fputs(msg, stderr);
106   }
107  
108 <
108 > extern void
109   quit(code)                              /* recover or quit */
110   int  code;
111   {
# Line 110 | Line 115 | int  code;
115   }
116  
117  
118 < mainmenu()                      /* the main menu loop */
118 > static void
119 > mainmenu(void)                  /* the main menu loop */
120   {
121          char  sbuf[128];
122  
# Line 128 | Line 134 | mainmenu()                     /* the main menu loop */
134                  printf("\t10    Quit\n");
135  
136                  printf("\nChoice: ");
137 <                clearerr(stdin); gets(sbuf);
137 >                clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin);
138                  if (feof(stdin))
139                          return;
140                  switch (atoi(sbuf)) {
# Line 159 | Line 165 | mainmenu()                     /* the main menu loop */
165                          break;
166                  case 6:                         /* set curve variable */
167                          printf("\nCurve (A-%c): ", MAXCUR-1+'A');
168 <                        clearerr(stdin); gets(sbuf);
168 >                        clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin);
169                          if (islower(sbuf[0]))
170                                  sbuf[0] -= 'a';
171                          else if (isupper(sbuf[0]))
# Line 174 | Line 180 | mainmenu()                     /* the main menu loop */
180                          break;
181                  case 8:                         /* escape command */
182                          printf("\nCommand: ");
183 <                        clearerr(stdin); gets(sbuf);
183 >                        clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin);
184                          if (sbuf[0]) {
185                                  system(sbuf);
186                                  uwait();
# Line 190 | Line 196 | mainmenu()                     /* the main menu loop */
196   }
197  
198  
199 < char *
200 < getfile()                       /* get file name from user */
199 > static char *
200 > getfile(void)                   /* get file name from user */
201   {
202          char  sbuf[128];
203  
204          printf("\nFile (%s): ", curfile);
205 <        clearerr(stdin); gets(sbuf);
205 >        clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin);
206          if (sbuf[0] == '-')
207                  return(NULL);
208          if (sbuf[0])
# Line 204 | Line 210 | getfile()                      /* get file name from user */
210          return(curfile);
211   }
212  
213 <
214 < settype()                       /* set plot type */
213 > static void
214 > settype(void)                   /* set plot type */
215   {
216          char  sbuf[128];
217          int  i;
# Line 216 | Line 222 | settype()                      /* set plot type */
222                  printf("\t%d    %s\n", i+1, typ[i].descrip);
223          
224          printf("\nChoice (0): ");
225 <        clearerr(stdin); gets(sbuf);
225 >        clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin);
226          i = atoi(sbuf) - 1;
227          if (i < 0 || i >= NTYP)
228                  return;
# Line 225 | Line 231 | settype()                      /* set plot type */
231   }
232  
233  
234 < plotout()                       /* output our graph */
234 > static void
235 > plotout(void)                   /* output our graph */
236   {
237          extern FILE  *pout;
238          char  sbuf[128];
# Line 240 | Line 247 | plotout()                      /* output our graph */
247          printf("\t%d    Other\n", NDEV+2);
248          
249          printf("\nChoice (0): ");
250 <        clearerr(stdin); gets(sbuf);
250 >        clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin);
251          i = atoi(sbuf) - 1;
252          if (i < 0 || i > NDEV+1)
253                  return;
# Line 256 | Line 263 | plotout()                      /* output our graph */
263                  return;
264          } else if (i == NDEV+1) {
265                  printf("\nDriver command: ");
266 <                clearerr(stdin); gets(sbuf);
266 >                clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin);
267                  if (!sbuf[0])
268                          return;
269                  command = sbuf;
# Line 277 | Line 284 | plotout()                      /* output our graph */
284   }
285  
286  
287 < setvars(nvar, vars)             /* set variables */
288 < int  nvar;
289 < VARIABLE  vars[];
287 > static void
288 > setvars(                /* set variables */
289 > int  nvar,
290 > VARIABLE  vars[])
291   {
292          char  sbuf[128];
293          int  i, j;
# Line 292 | Line 300 | VARIABLE  vars[];
300                                          vars[i].name : vars[i].descrip);
301  
302                  printf("\nChoice (0): ");
303 <                clearerr(stdin); gets(sbuf);
303 >                clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin);
304                  i = atoi(sbuf) - 1;
305                  if (i < 0 || i >= nvar)
306                          return;
# Line 309 | Line 317 | VARIABLE  vars[];
317                  else
318                          sprintf(sbuf, "%s=", vars[i].name);
319                  j = strlen(sbuf);
320 <                clearerr(stdin); gets(sbuf+j);
320 >                clearerr(stdin); fgets(sbuf+j, sizeof(sbuf)-j, stdin);
321                  if (sbuf[j]) {
322                          if (vars[i].type == DATA && sbuf[j] == '-')
323                                  sbuf[j] = '\0';
# Line 325 | Line 333 | VARIABLE  vars[];
333   }
334  
335  
336 < gcompute()                      /* do a computation */
336 > static void
337 > gcompute(void)                  /* do a computation */
338   {
339          char  sbuf[64];
340          int  i;
# Line 336 | Line 345 | gcompute()                     /* do a computation */
345                  printf("\t%d    %s\n", i+1, cal[i].descrip);
346          
347          printf("\nChoice (0): ");
348 <        clearerr(stdin); gets(sbuf);
348 >        clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin);
349          i = atoi(sbuf) - 1;
350          if (i < 0 || i >= NCAL)
351                  return;
# Line 351 | Line 360 | gcompute()                     /* do a computation */
360   }
361  
362  
363 < uwait()                         /* wait for user after command, error */
363 > static void
364 > uwait(void)                             /* wait for user after command, error */
365   {
366          printf("Hit return to continue: ");
367          while (getchar() != '\n')

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines