ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/badarg.c
Revision: 2.6
Committed: Fri Nov 14 17:22:06 2003 UTC (20 years, 5 months ago) by schorsch
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R7P2, rad3R7P1, rad4R1, rad4R0, rad3R6, rad3R6P1, rad3R8, rad3R9
Changes since 2.5: +6 -5 lines
Log Message:
Reduced compile warnings, and other compatibility fixes.

File Contents

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