-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_form_tag.c
66 lines (53 loc) · 960 Bytes
/
parse_form_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
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<errno.h>
#include"cgiaudit.h"
/*
@param pinit Initial pointer
@param forminfo structure to fill with FORM tag information
@return new pointer position
*/
static const char*err_str="While parsing FORM tag";
char*parse_form_tag(char*pinit,FORMINFO*forminfo)
{
char*p=pinit;
register char*oldp;
while(*p&&isspace(*p))
p++;
if(!*p)
syntax_error(err_str,1);
while(*p!='>')
{
oldp=p;
if(!strncasecmp(p,"NAME",4))
{
p+=4;
forminfo->name=isolate_value(&p);
}
if(!strncasecmp(p,"METHOD",6))
{
p+=6;
forminfo->method=isolate_value(&p);
}
if(!strncasecmp(p,"ACTION",6))
{
p+=6;
forminfo->action=isolate_value(&p);
}
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);
}
return p;
}