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 "meta.h" |
19 |
+ |
#include "mgraph.h" |
20 |
|
#include "mgvars.h" |
21 |
|
|
22 |
|
typedef struct { |
69 |
|
|
70 |
|
static char curfile[64] = "temp.plt"; /* current file name */ |
71 |
|
|
72 |
< |
char *getfile(), *gets(), *strcpy(); |
72 |
> |
static void mainmenu(void); |
73 |
> |
static void uwait(void); |
74 |
> |
static void gcompute(void); |
75 |
> |
static void setvars(int nvar, VARIABLE vars[]); |
76 |
> |
static void plotout(void); |
77 |
> |
static void settype(void); |
78 |
> |
static char *getfile(void); |
79 |
|
|
80 |
< |
|
80 |
> |
int |
81 |
|
main(argc, argv) |
82 |
|
int argc; |
83 |
|
char *argv[]; |
98 |
|
mainmenu(); |
99 |
|
|
100 |
|
quit(0); |
101 |
+ |
return 0; /* pro forma return */ |
102 |
|
} |
103 |
|
|
104 |
< |
|
104 |
> |
extern void |
105 |
|
eputs(msg) /* print error message */ |
106 |
|
char *msg; |
107 |
|
{ |
108 |
|
fputs(msg, stderr); |
109 |
|
} |
110 |
|
|
111 |
< |
|
111 |
> |
extern void |
112 |
|
quit(code) /* recover or quit */ |
113 |
|
int code; |
114 |
|
{ |
118 |
|
} |
119 |
|
|
120 |
|
|
121 |
< |
mainmenu() /* the main menu loop */ |
121 |
> |
static void |
122 |
> |
mainmenu(void) /* the main menu loop */ |
123 |
|
{ |
124 |
|
char sbuf[128]; |
125 |
|
|
137 |
|
printf("\t10 Quit\n"); |
138 |
|
|
139 |
|
printf("\nChoice: "); |
140 |
< |
clearerr(stdin); gets(sbuf); |
140 |
> |
clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin); |
141 |
|
if (feof(stdin)) |
142 |
|
return; |
143 |
|
switch (atoi(sbuf)) { |
168 |
|
break; |
169 |
|
case 6: /* set curve variable */ |
170 |
|
printf("\nCurve (A-%c): ", MAXCUR-1+'A'); |
171 |
< |
clearerr(stdin); gets(sbuf); |
171 |
> |
clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin); |
172 |
|
if (islower(sbuf[0])) |
173 |
|
sbuf[0] -= 'a'; |
174 |
|
else if (isupper(sbuf[0])) |
176 |
|
else |
177 |
|
break; |
178 |
|
if (sbuf[0] < MAXCUR) |
179 |
< |
setvars(NCVARS, cparam[sbuf[0]]); |
179 |
> |
setvars(NCVARS, cparam[(int)sbuf[0]]); |
180 |
|
break; |
181 |
|
case 7: /* output plot */ |
182 |
|
plotout(); |
183 |
|
break; |
184 |
|
case 8: /* escape command */ |
185 |
|
printf("\nCommand: "); |
186 |
< |
clearerr(stdin); gets(sbuf); |
186 |
> |
clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin); |
187 |
|
if (sbuf[0]) { |
188 |
|
system(sbuf); |
189 |
|
uwait(); |
199 |
|
} |
200 |
|
|
201 |
|
|
202 |
< |
char * |
203 |
< |
getfile() /* get file name from user */ |
202 |
> |
static char * |
203 |
> |
getfile(void) /* get file name from user */ |
204 |
|
{ |
205 |
|
char sbuf[128]; |
206 |
|
|
207 |
|
printf("\nFile (%s): ", curfile); |
208 |
< |
clearerr(stdin); gets(sbuf); |
208 |
> |
clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin); |
209 |
|
if (sbuf[0] == '-') |
210 |
|
return(NULL); |
211 |
|
if (sbuf[0]) |
213 |
|
return(curfile); |
214 |
|
} |
215 |
|
|
216 |
< |
|
217 |
< |
settype() /* set plot type */ |
216 |
> |
static void |
217 |
> |
settype(void) /* set plot type */ |
218 |
|
{ |
219 |
|
char sbuf[128]; |
220 |
|
int i; |
225 |
|
printf("\t%d %s\n", i+1, typ[i].descrip); |
226 |
|
|
227 |
|
printf("\nChoice (0): "); |
228 |
< |
clearerr(stdin); gets(sbuf); |
228 |
> |
clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin); |
229 |
|
i = atoi(sbuf) - 1; |
230 |
|
if (i < 0 || i >= NTYP) |
231 |
|
return; |
234 |
|
} |
235 |
|
|
236 |
|
|
237 |
< |
plotout() /* output our graph */ |
237 |
> |
static void |
238 |
> |
plotout(void) /* output our graph */ |
239 |
|
{ |
240 |
< |
extern FILE *pout, *popen(); |
240 |
> |
extern FILE *pout; |
241 |
|
char sbuf[128]; |
242 |
< |
char *command; |
242 |
> |
char *command = NULL; |
243 |
|
int i; |
244 |
|
|
245 |
|
printf("\nOUTPUT PLOT\n"); |
250 |
|
printf("\t%d Other\n", NDEV+2); |
251 |
|
|
252 |
|
printf("\nChoice (0): "); |
253 |
< |
clearerr(stdin); gets(sbuf); |
253 |
> |
clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin); |
254 |
|
i = atoi(sbuf) - 1; |
255 |
|
if (i < 0 || i > NDEV+1) |
256 |
|
return; |
266 |
|
return; |
267 |
|
} else if (i == NDEV+1) { |
268 |
|
printf("\nDriver command: "); |
269 |
< |
clearerr(stdin); gets(sbuf); |
269 |
> |
clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin); |
270 |
|
if (!sbuf[0]) |
271 |
|
return; |
272 |
|
command = sbuf; |
287 |
|
} |
288 |
|
|
289 |
|
|
290 |
< |
setvars(nvar, vars) /* set variables */ |
291 |
< |
int nvar; |
292 |
< |
VARIABLE vars[]; |
290 |
> |
static void |
291 |
> |
setvars( /* set variables */ |
292 |
> |
int nvar, |
293 |
> |
VARIABLE vars[]) |
294 |
|
{ |
295 |
|
char sbuf[128]; |
296 |
|
int i, j; |
303 |
|
vars[i].name : vars[i].descrip); |
304 |
|
|
305 |
|
printf("\nChoice (0): "); |
306 |
< |
clearerr(stdin); gets(sbuf); |
306 |
> |
clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin); |
307 |
|
i = atoi(sbuf) - 1; |
308 |
|
if (i < 0 || i >= nvar) |
309 |
|
return; |
320 |
|
else |
321 |
|
sprintf(sbuf, "%s=", vars[i].name); |
322 |
|
j = strlen(sbuf); |
323 |
< |
clearerr(stdin); gets(sbuf+j); |
323 |
> |
clearerr(stdin); fgets(sbuf+j, sizeof(sbuf)-j, stdin); |
324 |
|
if (sbuf[j]) { |
325 |
|
if (vars[i].type == DATA && sbuf[j] == '-') |
326 |
|
sbuf[j] = '\0'; |
336 |
|
} |
337 |
|
|
338 |
|
|
339 |
< |
gcompute() /* do a computation */ |
339 |
> |
static void |
340 |
> |
gcompute(void) /* do a computation */ |
341 |
|
{ |
342 |
|
char sbuf[64]; |
343 |
|
int i; |
348 |
|
printf("\t%d %s\n", i+1, cal[i].descrip); |
349 |
|
|
350 |
|
printf("\nChoice (0): "); |
351 |
< |
clearerr(stdin); gets(sbuf); |
351 |
> |
clearerr(stdin); fgets(sbuf, sizeof(sbuf), stdin); |
352 |
|
i = atoi(sbuf) - 1; |
353 |
|
if (i < 0 || i >= NCAL) |
354 |
|
return; |
363 |
|
} |
364 |
|
|
365 |
|
|
366 |
< |
uwait() /* wait for user after command, error */ |
366 |
> |
static void |
367 |
> |
uwait(void) /* wait for user after command, error */ |
368 |
|
{ |
369 |
|
printf("Hit return to continue: "); |
370 |
|
while (getchar() != '\n') |