Subversion Repositories Kolibri OS

Rev

Rev 8396 | Rev 8440 | 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
	char params[6000];
8396 leency 6
	bool opened;
7752 leency 7
	collection attributes;
8
	collection values;
9
	dword value;
8439 leency 10
	bool is();
7752 leency 11
	bool parse_tag();
8439 leency 12
	void debug_tag();
13
	bool get_next_param();
7752 leency 14
	dword get_value_of();
15
} tag=0;
7972 leency 16
7282 leency 17
 
7752 leency 18
{
19
	if ( !strcmp(#name, _text) ) {
8439 leency 20
		return true;
7752 leency 21
	} else {
22
		return false;
23
	}
24
}
25
26
 
8439 leency 27
{
7752 leency 28
	bool retok = true;
8439 leency 29
	dword bufpos = ESDWORD[_bufpos];
30
31
 
32
	dword whitepos;
33
34
 
35
	name = '\0';
36
	params = '\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
		goto _RET;
50
	}
51
52
 
53
		opened = false;
54
		bufpos++;
55
	} else {
56
		opened = true;
57
	}
58
59
 
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
 
77
		retok = false;
78
		goto _RET;
79
	}
80
81
 
82
83
 
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
 
93
94
 
95
	ESDWORD[_bufpos] = bufpos;
96
	return retok;
97
}
7752 leency 98
99
 
8439 leency 100
{
7752 leency 101
	if (debug_mode) {
8439 leency 102
		debugch('<');
103
		if (!opened) debugch('/');
104
		debug(#name);
105
		debugln(">");
106
		if (params) {
107
			debug("params: ");
108
			debugln(#params+1);
109
		}
110
	}
7282 leency 111
}
7752 leency 112
7282 leency 113
 
7752 leency 114
{
115
	byte  quotes = NULL;
116
	int   i;
117
	unsigned char  val[6000];
8396 leency 118
	unsigned char attr[6000];
119
7282 leency 120
 
7752 leency 121
122
 
123
	if (params[i] == '/') i--;
124
	while (i>0) && (__isWhite(params[i])) i--;
125
7282 leency 126
 
7752 leency 127
	{
7282 leency 128
		//remove quotes
7752 leency 129
		quotes = params[i];
130
		params[i] = '\0';
7970 leency 131
		i--;
7752 leency 132
7282 leency 133
 
134
		i = strrchr(#params, quotes);
7752 leency 135
		strlcpy(#val, #params + i, sizeof(val)-1);
136
		params[i] = '\0';
7970 leency 137
		i--;
7752 leency 138
7282 leency 139
 
140
		while (i > 0) && (params[i] != '=') i--;
7752 leency 141
		params[i+1] = '\0';
7970 leency 142
	}
7282 leency 143
	else
144
	{
145
		//find VAL start and copy
146
		while (i > 0) && (params[i] != '=') i--;
7752 leency 147
		i++;
7282 leency 148
		strlcpy(#val, #params + i, sizeof(val)-1);
7752 leency 149
7282 leency 150
 
7752 leency 151
	}
7282 leency 152
153
 
154
	while (i>0) && (!__isWhite(params[i])) i--;
7752 leency 155
	strlcpy(#attr, #params + i + 1, sizeof(attr)-1);
156
	params[i] = '\0';
157
7750 leency 158
 
159
	i = strchr(#attr,'=');
160
	if (!quotes) && (i) {
161
		strlcpy(#val, i+1, sizeof(val)-1);
162
		ESBYTE[i+1] = '\0';
163
	}
164
	strlwr(#attr);
7935 leency 165
	strrtrim(#val);
8020 leency 166
7282 leency 167
 
7752 leency 168
	values.add(#val);
169
7282 leency 170
 
8439 leency 171
		debug("atr: "); debugln(#attr);
172
		debug("val: "); debugln(#val);
173
		debugch('\n');
174
	}
175
176
 
7282 leency 177
}
178
179
 
7752 leency 180
{
181
	int pos = attributes.get_pos_by_name(_attr_name);
182
	if (pos == -1) {
183
		value = 0;
8439 leency 184
	} else {
7752 leency 185
		value = values.get(pos);
8439 leency 186
	}
7752 leency 187
	return value;
8439 leency 188
}
7752 leency 189