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 |
#define NULL 0 |
12 |
|
13 |
int |
14 |
badarg(ac, av, fl) /* check argument list */ |
15 |
int ac; |
16 |
register char **av; |
17 |
register char *fl; |
18 |
{ |
19 |
register int i; |
20 |
|
21 |
if (fl == NULL) |
22 |
fl = ""; /* no arguments? */ |
23 |
for (i = 1; *fl; i++,av++,fl++) { |
24 |
if (i > ac || *av == NULL) |
25 |
return(-1); |
26 |
switch (*fl) { |
27 |
case 's': /* string */ |
28 |
if (**av == '\0' || **av == ' ' || **av == '\t') |
29 |
return(i); |
30 |
break; |
31 |
case 'i': /* integer */ |
32 |
if (!isintd(*av, " \t")) |
33 |
return(i); |
34 |
break; |
35 |
case 'f': /* float */ |
36 |
if (!isfltd(*av, " \t")) |
37 |
return(i); |
38 |
break; |
39 |
default: /* bad call! */ |
40 |
return(-1); |
41 |
} |
42 |
} |
43 |
return(0); /* all's well */ |
44 |
} |