-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_select_tag.c
71 lines (57 loc) · 1.1 KB
/
parse_select_tag.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<errno.h>
#include"cgiaudit.h"
/*
@param pinit Initial pointer
@param inputinfo Structure to fill with SELECT tag information.
@return 0 on failure, 1 on success
*/
static const char*err_str="While parsing SELECT tag";
int parse_select_tag(char**pinit,SELECTINFO*selectinfo)
{
char*p=*pinit,*pa[1];
for(;*p&&isspace(*p);p++);
if(!*p)
syntax_error(err_str,1);
for(;*p&&*p!='>';p++)
{
if(!strncasecmp(p,"NAME",4))
{
p+=4;
pa[0]=p;
selectinfo->name=isolate_value(pa);
p=pa[0];
}
if(!strncasecmp(p,"VALUE",5))
{
p+=5;
selectinfo->value=isolate_value(&p);
if(!selectinfo->value)
syntax_error(err_str,0);
}
if(!strncasecmp(p,"SIZE",4))
{
char*p2;
p+=4;
pa[0]=p;
p2=isolate_value(pa);
p=pa[0];
selectinfo->size=strtoul(p,(char**)0,10);
if(errno==ERANGE)
syntax_error(err_str,0);
}
if(!strncasecmp(p,"MULTIPLE",7))
{
p+=7;
selectinfo->multiple=1;
}
while(*p&&!isspace(*p)&&*p!='>')
p++;
if(!*p)
syntax_error(err_str,1);
}
return 1;
}