Subversion Repositories Kolibri OS

Rev

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