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