Subversion Repositories Kolibri OS

Rev

Rev 8396 | Rev 8440 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8396 Rev 8439
Line 5... Line 5...
5
	char params[6000];
5
	char params[6000];
6
	bool opened;
6
	bool opened;
7
	collection attributes;
7
	collection attributes;
8
	collection values;
8
	collection values;
9
	bool is();
9
	dword value;
-
 
10
	bool is();
10
	bool reset();
11
	bool parse_tag();
11
	bool parse_params();
12
	void debug_tag();
12
	bool get_next_param();
13
	bool get_next_param();
13
	dword get_value_of();
14
	dword get_value_of();
14
} tag=0;
15
} tag=0;
15
 
16
 
Line 16... Line 17...
16
bool _tag::is(dword _text) 
17
bool _tag::is(dword _text) 
17
{ 
18
{ 
18
	if ( !strcmp(#tag.name, _text) ) {
19
	if ( !strcmp(#name, _text) ) {
19
		return true;
20
		return true;
20
	} else {
21
	} else {
21
		return false; 
22
		return false; 
22
	}
23
	}
23
}
24
}
Line 24... Line 25...
24
 
25
 
25
bool _tag::reset()
26
bool _tag::parse_tag(dword _bufpos, bufend)
26
{
27
{
-
 
28
	bool retok = true;
-
 
29
	dword bufpos = ESDWORD[_bufpos];
-
 
30
 
-
 
31
	dword closepos;
-
 
32
	dword whitepos;
27
	if (!name) return false;
33
 
28
	strcpy(#prior, #name);
34
	if (name) strcpy(#prior, #name); else prior = '\0';
29
	name = NULL;
35
	name = '\0';
30
	opened = true;
36
	params = '\0';
31
	attributes.drop();
37
	attributes.drop();
-
 
38
	values.drop();		
-
 
39
 
-
 
40
	if (!strncmp(bufpos,"!--",3))
32
	values.drop();
41
	{
-
 
42
		bufpos+=3;
-
 
43
		//STRSTR
-
 
44
		while (strncmp(bufpos,"-->",3)!=0) && (bufpos < bufend)
-
 
45
		{
-
 
46
			bufpos++;
-
 
47
		}
-
 
48
		bufpos+=2;
33
	return true;
49
		goto _RET;
Line -... Line 50...
-
 
50
	}
-
 
51
 
-
 
52
	if (ESBYTE[bufpos] == '/') {
-
 
53
		opened = false;
-
 
54
		bufpos++;
-
 
55
	} else {
-
 
56
		opened = true;
-
 
57
	}
-
 
58
 
-
 
59
	closepos = strchr(bufpos, '>');
-
 
60
	whitepos = strchrw(bufpos, bufend-bufpos);
-
 
61
	if (whitepos > closepos) {
-
 
62
		//no param
-
 
63
		strncpy(#name, bufpos, math.min(closepos - bufpos, sizeof(tag.name)));
-
 
64
		debug_tag();
-
 
65
		params = '\0';
-
 
66
		bufpos = closepos;
-
 
67
	} else {
-
 
68
		//we have param
-
 
69
		strncpy(#name, bufpos, math.min(whitepos - bufpos, sizeof(tag.name)));
-
 
70
		strncpy(#params, whitepos, math.min(closepos - whitepos, sizeof(tag.params)));
-
 
71
		debug_tag();
-
 
72
		bufpos = closepos;
-
 
73
		while (get_next_param());
-
 
74
	}
-
 
75
 
-
 
76
	if (!name) {
-
 
77
		retok = false;
-
 
78
		goto _RET;
-
 
79
	}
-
 
80
 
-
 
81
	strlwr(#name);
-
 
82
 
-
 
83
	// ignore text inside the next tags
-
 
84
	if (is("script")) || (is("style")) || (is("binary")) || (is("select")) { 
-
 
85
		strcpy(#prior, #name);
-
 
86
		sprintf(#name, "", #prior);
-
 
87
		if (strstri(bufpos, #name)) bufpos = EAX-1;
-
 
88
		retok = false;
-
 
89
		goto _RET;
-
 
90
	}
-
 
91
 
-
 
92
	if (name[strlen(#name)-1]=='/') name[strlen(#name)-1]=NULL; //for 
-
 
93
 
-
 
94
_RET:
-
 
95
	ESDWORD[_bufpos] = bufpos;
-
 
96
	return retok;
34
}
97
}
35
 
98
 
36
bool _tag::parse_params()
-
 
37
{
-
 
38
	bool result = false;
99
void _tag::debug_tag()
-
 
100
{
39
	if (!name) return false;
101
	if (debug_mode) { 
40
	if (debug_mode) {
102
		debugch('<'); 
41
		debug("\n\ntag: "); debugln(#name);
103
		if (!opened) debugch('/');
-
 
104
		debug(#name);
-
 
105
		debugln(">");
-
 
106
		if (params) {
42
		debug("params: "); debugln(#params);
107
			debug("params: "); 
43
		debugln(" ");
-
 
44
	}
-
 
45
	while (get_next_param()) {
-
 
46
		result = true;
-
 
47
		if (debug_mode) {
-
 
48
			debug("attribute: "); debugln(attributes.get(attributes.count-1));
-
 
49
			debug("value: "); debugln(values.get(values.count-1));
108
			debugln(#params+1);
50
			debugln(" ");
-
 
51
		}
-
 
52
	};
109
		}
Line 53... Line 110...
53
	return result;
110
	}
54
}
111
}
55
 
112
 
Line 109... Line 166...
109
 
166
 
Line 110... Line 167...
110
	attributes.add(#attr);
167
	attributes.add(#attr);
111
	values.add(#val);
168
	values.add(#val);
Line -... Line 169...
-
 
169
 
-
 
170
	if (debug_mode) {
-
 
171
		debug("atr: "); debugln(#attr);
-
 
172
		debug("val: "); debugln(#val);
-
 
173
		debugch('\n');
-
 
174
	}
112
 
175
 
113
	return true;
176
	return true;
Line 114... Line 177...
114
}
177
}
115
 
178
 
116
dword _tag::get_value_of(dword _attr_name)
179
dword _tag::get_value_of(dword _attr_name)
117
{
180
{
118
	int pos = attributes.get_pos_by_name(_attr_name);
181
	int pos = attributes.get_pos_by_name(_attr_name);
119
	if (pos == -1) {
182
	if (pos == -1) {
120
		return 0;
183
		value = 0;
121
	} else {
184
	} else {
-
 
185
		value = values.get(pos);
122
		return values.get(pos);
186
	}