home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
NEWS
/
RADIANCE
/
SRC
/
COMMON
/
BADARG.C
next >
Wrap
C/C++ Source or Header
|
1993-10-07
|
880b
|
47 lines
/* Copyright (c) 1991 Regents of the University of California */
#ifndef lint
static char SCCSid[] = "@(#)badarg.c 2.1 11/12/91 LBL";
#endif
/*
* Check argument list against format string.
*/
#include <ctype.h>
#define NULL 0
int
badarg(ac, av, fl) /* check argument list */
int ac;
register char **av;
register char *fl;
{
register int i;
if (fl == NULL)
fl = ""; /* no arguments? */
for (i = 1; *fl; i++,av++,fl++) {
if (i > ac || *av == NULL)
return(-1);
switch (*fl) {
case 's': /* string */
if (**av == '\0' || isspace(**av))
return(i);
break;
case 'i': /* integer */
if (!isintd(*av, " \t\r\n"))
return(i);
break;
case 'f': /* float */
if (!isfltd(*av, " \t\r\n"))
return(i);
break;
default: /* bad call! */
return(-1);
}
}
return(0); /* all's well */
}