-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_input_tag.c
105 lines (89 loc) · 1.61 KB
/
parse_input_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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#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 INPUT tag information.
@return 0 on failure, 1 on success
*/
static const char*err_str="While parsing INPUT tag";
int parse_input_tag(char**porig,INPUTINFO*inputinfo)
{
char*p=*porig;
register char*oldp;
while(*p!='>')
{
oldp=p;
if(!strncasecmp(p,"NAME",4))
{
p+=4;
inputinfo->name=isolate_value(&p);
if(!inputinfo->name)
syntax_error(err_str,0);
}
if(!strncasecmp(p,"VALUE",5))
{
p+=5;
inputinfo->value=isolate_value(&p);
if(!inputinfo->value)
syntax_error(err_str,0);
}
if(!strncasecmp(p,"CHECKED",7))
{
p+=7;
inputinfo->checked=1;
}
if(!strncasecmp(p,"SIZE",4))
{
p+=4;
inputinfo->size=isolate_value(&p);
if(!inputinfo->size)
return 1;
}
if(!strncasecmp(p,"MAXLENGTH",9))
{
char*p2;
p+=9;
p2=isolate_value(&p);
inputinfo->maxlength=strtoul(p2,(char**)0,10);
if(!inputinfo->maxlength)
return 1;
if(errno==ERANGE)
syntax_error(err_str,0);
free(p2);
}
if(!strncasecmp(p,"SRC",3))
{
p+=3;
inputinfo->src=isolate_value(&p);
if(!inputinfo->src)
return 1;
}
if(!strncasecmp(p,"ALIGN",5))
{
p+=5;
inputinfo->align=isolate_value(&p);
if(!inputinfo->align)
return 1;
}
if(oldp==p)
{
if(!isspace(*p))
do
{
if(*p=='>')
break;
p++;
} while(*p&&!isspace(*p));
while(*p&&isspace(*p))
p++;
}
if(!*p)
syntax_error(err_str,1);
}
*porig=p;
return 1;
}