Subversion Repositories Kolibri OS

Rev

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