1 |
– |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Read white space separated values from stream |
6 |
+ |
* |
7 |
+ |
* External symbols declared in rtio.h |
8 |
|
*/ |
9 |
|
|
10 |
< |
#include <stdio.h> |
10 |
> |
#include "rtio.h" |
11 |
|
|
12 |
|
#include <math.h> |
14 |
– |
|
13 |
|
#include <ctype.h> |
14 |
|
|
17 |
– |
|
18 |
– |
#ifdef DCL_ATOF |
19 |
– |
extern double atof(); |
20 |
– |
#endif |
21 |
– |
extern int atoi(); |
22 |
– |
extern long atol(); |
23 |
– |
extern char *strcpy(); |
24 |
– |
|
25 |
– |
|
15 |
|
int |
16 |
|
fgetval(fp, ty, vp) /* get specified data word */ |
17 |
|
register FILE *fp; |
18 |
|
int ty; |
19 |
|
char *vp; |
20 |
|
{ |
32 |
– |
static char delims[] = " \t\n\r\f#"; |
21 |
|
char wrd[64]; |
22 |
|
register char *cp; |
23 |
|
register int c; |
43 |
|
*cp = '\0'; |
44 |
|
switch (ty) { /* check and convert it */ |
45 |
|
case 'h': /* short */ |
46 |
< |
if (!isintd(wrd, delims)) |
46 |
> |
if (!isint(wrd)) |
47 |
|
return(0); |
48 |
|
*(short *)vp = c = atoi(wrd); |
49 |
|
if (*(short *)vp != c) |
50 |
|
return(0); |
51 |
|
return(1); |
52 |
|
case 'i': /* integer */ |
53 |
< |
if (!isintd(wrd, delims)) |
53 |
> |
if (!isint(wrd)) |
54 |
|
return(0); |
55 |
|
*(int *)vp = atoi(wrd); |
56 |
|
return(1); |
57 |
|
case 'l': /* long */ |
58 |
< |
if (!isintd(wrd, delims)) |
58 |
> |
if (!isint(wrd)) |
59 |
|
return(0); |
60 |
|
*(long *)vp = atol(wrd); |
61 |
|
return(1); |
62 |
|
case 'f': /* float */ |
63 |
< |
if (!isfltd(wrd, delims)) |
63 |
> |
if (!isflt(wrd)) |
64 |
|
return(0); |
65 |
|
*(float *)vp = atof(wrd); |
66 |
|
return(1); |
67 |
|
case 'd': /* double */ |
68 |
< |
if (!isfltd(wrd, delims)) |
68 |
> |
if (!isflt(wrd)) |
69 |
|
return(0); |
70 |
|
*(double *)vp = atof(wrd); |
71 |
|
return(1); |