1 |
greg |
1.1 |
#ifndef lint |
2 |
greg |
2.2 |
static const char RCSid[] = "$Id$"; |
3 |
greg |
1.1 |
#endif |
4 |
|
|
/* |
5 |
|
|
* Check argument list against format string. |
6 |
greg |
2.2 |
* |
7 |
|
|
* External symbols declared in standard.h |
8 |
|
|
*/ |
9 |
|
|
|
10 |
greg |
2.3 |
#include "copyright.h" |
11 |
greg |
1.1 |
|
12 |
greg |
1.2 |
#include <ctype.h> |
13 |
|
|
|
14 |
greg |
1.1 |
#define NULL 0 |
15 |
|
|
|
16 |
|
|
int |
17 |
|
|
badarg(ac, av, fl) /* check argument list */ |
18 |
|
|
int ac; |
19 |
|
|
register char **av; |
20 |
|
|
register char *fl; |
21 |
|
|
{ |
22 |
|
|
register int i; |
23 |
|
|
|
24 |
|
|
if (fl == NULL) |
25 |
|
|
fl = ""; /* no arguments? */ |
26 |
|
|
for (i = 1; *fl; i++,av++,fl++) { |
27 |
|
|
if (i > ac || *av == NULL) |
28 |
|
|
return(-1); |
29 |
|
|
switch (*fl) { |
30 |
|
|
case 's': /* string */ |
31 |
greg |
1.2 |
if (**av == '\0' || isspace(**av)) |
32 |
greg |
1.1 |
return(i); |
33 |
|
|
break; |
34 |
|
|
case 'i': /* integer */ |
35 |
greg |
1.2 |
if (!isintd(*av, " \t\r\n")) |
36 |
greg |
1.1 |
return(i); |
37 |
|
|
break; |
38 |
|
|
case 'f': /* float */ |
39 |
greg |
1.2 |
if (!isfltd(*av, " \t\r\n")) |
40 |
greg |
1.1 |
return(i); |
41 |
|
|
break; |
42 |
|
|
default: /* bad call! */ |
43 |
|
|
return(-1); |
44 |
|
|
} |
45 |
|
|
} |
46 |
|
|
return(0); /* all's well */ |
47 |
|
|
} |