8 |
|
*/ |
9 |
|
|
10 |
|
#include <stdlib.h> |
11 |
+ |
#include <fcntl.h> |
12 |
|
#include <stdio.h> |
13 |
|
#include <string.h> |
14 |
|
#include <math.h> |
15 |
|
#include <ctype.h> |
16 |
|
|
17 |
|
#include "platform.h" |
17 |
– |
#include "calcomp.h" |
18 |
|
#include "rterror.h" |
19 |
+ |
#include "rtmisc.h" |
20 |
+ |
#include "rtio.h" |
21 |
+ |
#include "calcomp.h" |
22 |
|
|
23 |
|
#define isnum(c) (isdigit(c) || (c)=='-' || (c)=='.' \ |
24 |
|
|| (c)=='+' || (c)=='e' || (c)=='E') |
57 |
|
#define savqstr(s) strcpy(emalloc(strlen(s)+1),s) |
58 |
|
#define freqstr(s) efree(s) |
59 |
|
|
60 |
+ |
static int getinputrec(FILE *fp); |
61 |
|
static void scaninp(void), advinp(void), resetinp(void); |
62 |
|
static void putrec(void), putout(void), nbsynch(void); |
63 |
|
static int getrec(void); |
70 |
|
static void chanset(int n, double v); |
71 |
|
static void bchanset(int n, double v); |
72 |
|
static struct strvar* getsvar(char *svname); |
73 |
+ |
static double l_in(char *); |
74 |
|
|
75 |
|
struct field *inpfmt = NULL; /* input record format */ |
76 |
|
struct field *outfmt = NULL; /* output record structure */ |
114 |
|
biggerlib(); |
115 |
|
#endif |
116 |
|
varset("PI", ':', 3.14159265358979323846); |
117 |
+ |
funset("in", 1, '=', &l_in); |
118 |
|
|
119 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
120 |
|
switch (argv[i][1]) { |
221 |
|
execute(argv[i]); |
222 |
|
|
223 |
|
quit(0); |
224 |
+ |
return 0; /* pro forma return */ |
225 |
|
} |
226 |
|
|
227 |
|
|
237 |
|
} |
238 |
|
|
239 |
|
|
240 |
< |
int |
240 |
> |
static int |
241 |
|
getinputrec( /* get next input record */ |
242 |
|
FILE *fp |
243 |
|
) |
304 |
|
fflush(stdout); |
305 |
|
} |
306 |
|
|
307 |
+ |
|
308 |
+ |
static double |
309 |
+ |
l_in(char *funame) /* function call for $channel */ |
310 |
+ |
{ |
311 |
+ |
int n; |
312 |
+ |
register char *cp; |
313 |
+ |
/* get argument as integer */ |
314 |
+ |
n = (int)(argument(1) + .5); |
315 |
+ |
if (n != 0) /* return channel value */ |
316 |
+ |
return(chanvalue(n)); |
317 |
+ |
/* determine number of channels */ |
318 |
+ |
if (noinput || inpfmt != NULL) |
319 |
+ |
return(0); |
320 |
+ |
if (nbicols > 0) |
321 |
+ |
return(nbicols); |
322 |
+ |
if (nbicols < 0) |
323 |
+ |
return(-nbicols); |
324 |
+ |
cp = inpbuf; /* need to count */ |
325 |
+ |
for (n = 0; *cp; ) |
326 |
+ |
if (blnkeq && isspace(sepchar)) { |
327 |
+ |
while (isspace(*cp)) |
328 |
+ |
cp++; |
329 |
+ |
n += *cp != '\0'; |
330 |
+ |
while (*cp && !isspace(*cp)) |
331 |
+ |
cp++; |
332 |
+ |
} else { |
333 |
+ |
n += *cp != '\n'; |
334 |
+ |
while (*cp && *cp++ != sepchar) |
335 |
+ |
; |
336 |
+ |
} |
337 |
+ |
return(n); |
338 |
+ |
} |
339 |
|
|
340 |
|
double |
341 |
|
chanvalue( /* return value for column n */ |