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