Subversion Repositories Kolibri OS

Rev

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

Rev 7750 Rev 7752
Line -... Line 1...
-
 
1
struct _tag
1
bool GetNextParam()
2
{
2
{
3
	char name[32];
-
 
4
	char params[5000];
-
 
5
	bool opened;
-
 
6
	collection attributes;
-
 
7
	collection values;
3
	byte  quotes = NULL;
8
	bool is();
4
	int   i;
9
	bool reset();
-
 
10
	bool parse_params();
-
 
11
	bool get_next_param();
-
 
12
	dword get_value_of();
-
 
13
} tag;
-
 
14
 
Line -... Line 15...
-
 
15
bool _tag::is(dword _text) 
-
 
16
{ 
-
 
17
	if ( !strcmp(#tag.name, _text) ) {
-
 
18
		return true;
-
 
19
	} else {
5
	
20
		return false; 
-
 
21
	}
-
 
22
}
Line -... Line 23...
-
 
23
 
-
 
24
bool _tag::reset()
-
 
25
{
-
 
26
	if (!name) return false;
-
 
27
	name = NULL;
-
 
28
	opened = true;
-
 
29
	attributes.drop();
-
 
30
	values.drop();
-
 
31
	attributes.add("ZERO");
-
 
32
	values.add("NULL");
-
 
33
	return true;
-
 
34
}
-
 
35
 
-
 
36
bool _tag::parse_params()
-
 
37
{
-
 
38
	bool result = false;
-
 
39
	if (!name) return false;
-
 
40
	if (debug_mode) {
-
 
41
		debugln(" ");
-
 
42
		debugln(" ");
-
 
43
		debug("tag: "); debugln(#name);
-
 
44
		debug("params: "); debugln(#params);
-
 
45
		debugln(" ");
-
 
46
	}
-
 
47
	while (get_next_param()) {
6
	if (!tagparam) return false;
48
		result = true;
7
 
49
		if (debug_mode) {
8
	if (debug_mode) {
50
			debug("attribute: "); debugln(attributes.get(attributes.count-1));
-
 
51
			debug("value: "); debugln(values.get(values.count-1));
-
 
52
			debugln(" ");
-
 
53
		}
-
 
54
	};
9
		debug("tag: "); debugln(#tag);
55
	return result;
Line 10... Line 56...
10
		debug("tagparam: "); debugln(#tagparam);
56
}
-
 
57
 
-
 
58
bool _tag::get_next_param()
-
 
59
{
-
 
60
	byte  quotes = NULL;
-
 
61
	int   i;
Line 11... Line 62...
11
	}
62
	unsigned char  val[4000];
Line -... Line 63...
-
 
63
	unsigned char attr[4000];
-
 
64
 
12
	
65
	if (!params) return false;
Line 13... Line 66...
13
	i = strlen(#tagparam) - 1;
66
	
14
 
67
	i = strlen(#params) - 1;
15
	if (tagparam[i] == '/') i--;
68
	if (params[i] == '/') i--;
16
 
69
	while (i>0) && (__isWhite(params[i])) i--;
17
	while (i>0) && (__isWhite(tagparam[i])) i--;
70
 
-
 
71
	if (params[i] == '"') || (params[i] == '\'')
Line 18... Line 72...
18
 
72
	{
19
	if (tagparam[i] == '"') || (tagparam[i] == '\'')
73
		//remove quotes
20
	{
74
		quotes = params[i];
21
		//find VAL end
75
		params[i] = EOS;
-
 
76
		i--;
Line 22... Line 77...
22
		quotes = tagparam[i];
77
 
23
		tagparam[i] = '\0'; i--;
78
		//find VAL start and copy
24
 
79
		i = strrchr(#params, quotes);
25
		//find VAL start and copy
80
		strlcpy(#val, #params + i, sizeof(val)-1);
26
		i = strrchr(#tagparam, quotes);
81
		params[i] = EOS; 
27
		strlcpy(#val, #tagparam + i, sizeof(val)-1);
82
		i--;
28
		tagparam[i] = '\0'; i--;
-
 
29
 
-
 
30
		//find ATTR end
-
 
31
		while (i > 0) && (tagparam[i] != '=') i--;
83
 
32
		tagparam[i+1] = '\0';
84
		//find ATTR end
33
	}
85
		while (i > 0) && (params[i] != '=') i--;
34
	else
86
		params[i+1] = EOS;
35
	{
-
 
Line 36... Line -...
36
		//find VAL end
-
 
37
		//already have
87
	}
38
 
88
	else
Line 39... Line 89...
39
		//find VAL start and copy
89
	{
40
		while (i > 0) && (tagparam[i] != '=') i--;
90
		//find VAL start and copy
41
		i++;
91
		while (i > 0) && (params[i] != '=') i--;
-
 
92
		i++;
42
		strlcpy(#val, #tagparam + i, sizeof(val)-1);
93
		strlcpy(#val, #params + i, sizeof(val)-1);
Line 43... Line 94...
43
		// tagparam[i] = '\0';
94
 
44
 
95
		//already have ATTR end
45
		//find ATTR end
96
	}
46
		//already have
97
 
47
	}
98
	//find ATTR start and copy
48
 
99
	while (i>0) && (!__isWhite(params[i])) i--;
Line 49... Line 100...
49
	//find ATTR start and copy
100
	strlcpy(#attr, #params + i + 1, sizeof(attr)-1);
50
	while (i>0) && (!__isWhite(tagparam[i])) i--;
-
 
51
	strlcpy(#attr, #tagparam + i + 1, sizeof(attr)-1);
-
 
52
	tagparam[i] = '\0';
-
 
53
 
-
 
54
	//fix case: src=./images/KolibriOS_logo2.jpg?sid=e8ece8b38b
101
	strlwr(#attr);
55
	i = strchr(#attr,'=');
-
 
Line 56... Line 102...
56
	if (!quotes) && (i) {
102
	params[i] = '\0';
57
		strlcpy(#val, i+1, sizeof(val)-1);
103
 
Line -... Line 104...
-
 
104
	//fix case: src=./images/KolibriOS_logo2.jpg?sid=e8ece8b38b
58
		ESBYTE[i+1] = '\0';
105
	i = strchr(#attr,'=');
-
 
106
	if (!quotes) && (i) {
-
 
107
		strlcpy(#val, i+1, sizeof(val)-1);
-
 
108
		ESBYTE[i+1] = '\0';
-
 
109
	}
-
 
110
 
-
 
111
	attributes.add(#attr);
-
 
112
	values.add(#val);