Subversion Repositories Kolibri OS

Rev

Rev 8490 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7752 leency 1
 
2
{
4411 leency 3
	char name[32];
7752 leency 4
	char prior[32];
7756 leency 5
	bool opened;
7752 leency 6
	collection attributes;
7
	collection values;
8
	dword value;
8439 leency 9
	dword number;
8500 leency 10
	bool is();
7752 leency 11
	bool parse();
8440 leency 12
	void debug_tag();
8439 leency 13
	dword get_next_param();
8440 leency 14
	dword get_value_of();
7752 leency 15
	signed get_number_of();
8500 leency 16
} tag=0;
7972 leency 17
7282 leency 18
 
7752 leency 19
{
20
	if ( !strcmp(#name, _text) ) {
8439 leency 21
		return true;
7752 leency 22
	} else {
23
		return false;
24
	}
25
}
26
27
 
8440 leency 28
{
7752 leency 29
	bool retok = true;
8439 leency 30
	dword bufpos = ESDWORD[_bufpos];
31
	dword params, paramsend;
8440 leency 32
8439 leency 33
 
34
	dword whitepos;
35
	dword openpos;
8490 leency 36
8439 leency 37
 
38
	name = '\0';
39
	attributes.drop();
7752 leency 40
	values.drop();
8439 leency 41
42
 
43
	{
44
		bufpos+=3;
45
		//STRSTR
46
		while (strncmp(bufpos,"-->",3)!=0) && (bufpos < bufend)
47
		{
48
			bufpos++;
49
		}
50
		bufpos+=2;
51
		retok = false;
8440 leency 52
		goto _RET;
8439 leency 53
	}
54
55
 
56
		opened = false;
57
		bufpos++;
58
	} else {
59
		opened = true;
60
	}
61
62
 
63
	whitepos = strchrw(bufpos, bufend-bufpos);
64
8440 leency 65
 
66
		if (!closepos) debugln("null closepos");
67
		if (!whitepos) debugln("null whitepos");
68
	}
69
70
 
71
		//no param
8439 leency 72
		strncpy(#name, bufpos, math.min(closepos - bufpos, sizeof(tag.name)));
73
		debug_tag();
74
		bufpos = closepos;
75
	} else {
76
		//we have param
77
		while (chrlnum(whitepos, '\"', closepos - whitepos)%2) { //alt="Next>>"
8490 leency 78
			/*
79
			openpos = strchr(closepos+1, '<');
80
			closepos = strchr(closepos+1, '>');
81
			if (openpos) && (openpos < closepos) {
82
				closepos = openpos - 1;
83
				break;
84
			}
85
			*/
86
			if (!openpos = strchr(closepos+1, '<')) break;
87
			if (openpos < strchr(closepos+1, '>')) break;
88
			if (!closepos = EAX) {closepos = bufend;break;}
89
		}
90
		strncpy(#name, bufpos, math.min(whitepos - bufpos, sizeof(tag.name)));
8439 leency 91
		debug_tag();
92
		bufpos = closepos;
93
94
 
8440 leency 95
		strncpy(params, whitepos, closepos - whitepos);
96
		if (debug_mode) { debug("params: "); debugln(params+1); }
97
		paramsend = params + closepos - whitepos;
98
		while (paramsend = get_next_param(params, paramsend-1));
99
		free(params);
100
	}
8439 leency 101
102
 
8440 leency 103
		strlwr(#name);
104
		// ignore text inside the next tags
105
		if (is("script")) || (is("style")) || (is("binary")) || (is("select")) {
106
			strcpy(#prior, #name);
107
			sprintf(#name, "", #prior);
108
			if (strstri(bufpos, #name)) bufpos = EAX-1;
109
			retok = false;
110
		} else {
111
			if (name[strlen(#name)-1]=='/') name[strlen(#name)-1]=NULL; //for 
112
		}
113
	} else {
114
		retok = false;
8439 leency 115
	}
116
117
 
118
	ESDWORD[_bufpos] = bufpos;
119
	return retok;
120
}
7752 leency 121
122
 
8439 leency 123
{
7752 leency 124
	if (debug_mode) {
8439 leency 125
		debugch('<');
126
		if (!opened) debugch('/');
127
		debug(#name);
128
		debugln(">");
129
	}
7282 leency 130
}
7752 leency 131
7282 leency 132
 
8440 leency 133
{
7752 leency 134
	// "ps" - param start
8440 leency 135
	// "pe" - param end
136
	// "q"  - quote char
137
	char q = NULL;
138
	dword fixeq;
139
	dword val;
8445 leency 140
	dword attr;
8443 leency 141
7752 leency 142
 
8440 leency 143
	while (pe>ps) && (__isWhite(ESBYTE[pe])) pe--;
144
7282 leency 145
 
8440 leency 146
	{
7282 leency 147
		//remove quote
8440 leency 148
		q = ESBYTE[pe];
149
		ESBYTE[pe] = '\0';
150
		pe--;
151
7282 leency 152
 
153
		pe = strrchr(ps, q) + ps;
8440 leency 154
		val = pe;
8445 leency 155
		pe--;
156
		ESBYTE[pe] = '\0';
8440 leency 157
7282 leency 158
 
159
		while (pe > ps) && (ESBYTE[pe] != '=') pe--;
8440 leency 160
		ESBYTE[pe] = '\0';
8444 leency 161
	}
7282 leency 162
	else
163
	{
164
		//find VAL start and copy
165
		while (pe > ps) && (ESBYTE[pe] != '=') pe--;
8440 leency 166
		val = pe+1;
8445 leency 167
		ESBYTE[pe] = '\0';
8444 leency 168
		//already have ATTR end
7752 leency 169
	}
7282 leency 170
171
 
172
	while (pe>ps) && (!__isWhite(ESBYTE[pe])) pe--;
8440 leency 173
	attr = pe + 1;
8443 leency 174
	ESBYTE[pe] = '\0';
8440 leency 175
8445 leency 176
 
177
	// Exchange '=' and '\0' position.
178
	// attr: src=./images/logo?sid   =>   src
179
	// val:  e8ece8b38b              =>   ./images/logo?sid=e8ece8b38b
180
	fixeq = strchr(attr,'=');
8443 leency 181
	if (!q) && (fixeq) {
8440 leency 182
		ESBYTE[val-1] >< ESBYTE[fixeq];
8445 leency 183
		val = fixeq+1;
184
	}
7750 leency 185
	strlwr(attr);
8443 leency 186
	strrtrim(val);
8445 leency 187
7282 leency 188
 
8443 leency 189
	values.add(val);
8445 leency 190
7282 leency 191
 
8439 leency 192
		debug("atr: "); debugln(attr);
8443 leency 193
		debug("val: "); debugln(val);
8445 leency 194
		debugch('\n');
8439 leency 195
	}
196
197
 
8440 leency 198
	return pe;
199
}
7282 leency 200
201
 
7752 leency 202
{
203
	int pos = attributes.get_pos_by_name(_attr_name);
204
	if (pos == -1) {
205
		value = 0;
8439 leency 206
	} else {
7752 leency 207
		value = values.get(pos);
8439 leency 208
	}
7752 leency 209
	return value;
8439 leency 210
}
7752 leency 211
8500 leency 212
 
213
{
214
	if (get_value_of(_attr_name)) {
215
		number = atoi(tag.value);
216
	} else {
217
		number = 0;
218
	}
219
	return number;
220
}
221
>