-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_textarea_tag.c
85 lines (69 loc) · 1.35 KB
/
parse_textarea_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
#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 TEXTAREA tag information.
@return 0 on failure, 1 on success
*/
static const char*err_str="While parsing TEXTAREA tag";
int parse_textarea_tag(char**pinit,TEXTAREAINFO*textareainfo)
{
char*p=*pinit,*pa[1];
for(;*p&&isspace(*p);p++);
if(!*p)
syntax_error(err_str,1);
for(;*p&&*p!='>';)
{
if(!strncasecmp(p,"NAME",4))
{
p+=4;
pa[0]=p;
textareainfo->name=isolate_value(pa);
p=pa[0];
continue;
}
if(!strncasecmp(p,"ROWS",4))
{
char*p2;
p+=4;
pa[0]=p;
p2=isolate_value(pa);
p=pa[0];
textareainfo->rows=strtoul(p2,(char**)0,10);
if(errno==ERANGE)
syntax_error(err_str,1);
continue;
}
if(!strncasecmp(p,"COLS",4))
{
char*p2;
p+=4;
pa[0]=p;
p2=isolate_value(pa);
p=pa[0];
textareainfo->cols=strtoul(p2,(char**)0,10);
if(errno==ERANGE)
syntax_error(err_str,1);
continue;
}
if(!strncasecmp(p,"VALUE",5))
{
p+=5;
textareainfo->value=isolate_value(&p);
if(!textareainfo->value)
syntax_error(err_str,0);
}
while(*p&&isspace(*p))
p++;
if(!*p)
syntax_error(err_str,1);
p++;
}
if(!textareainfo->rows||!textareainfo->cols)
syntax_error(err_str,1);
return 1;
}