Subversion Repositories Kolibri OS

Rev

Rev 7746 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7746 Rev 7750
1
bool GetNextParam()
1
bool GetNextParam()
2
{
2
{
3
	byte  quotes = NULL;
3
	byte  quotes = NULL;
4
	int   i;
4
	int   i;
5
	
5
	
6
	if (!tagparam) return false;
6
	if (!tagparam) return false;
7
 
7
 
8
	if (debug_mode) {
8
	if (debug_mode) {
-
 
9
		debug("tag: "); debugln(#tag);
9
		debug("tagparam: "); debugln(#tagparam);
10
		debug("tagparam: "); debugln(#tagparam);
10
	}
11
	}
11
	
12
	
12
	i = strlen(#tagparam) - 1;
13
	i = strlen(#tagparam) - 1;
13
 
14
 
14
	if (tagparam[i] == '/') i--;
15
	if (tagparam[i] == '/') i--;
15
 
16
 
16
	while (i>0) && (__isWhite(tagparam[i])) i--;
17
	while (i>0) && (__isWhite(tagparam[i])) i--;
17
 
18
 
18
	if (tagparam[i] == '"') || (tagparam[i] == '\'')
19
	if (tagparam[i] == '"') || (tagparam[i] == '\'')
19
	{
20
	{
20
		//find VAL end
21
		//find VAL end
21
		quotes = tagparam[i];
22
		quotes = tagparam[i];
22
		tagparam[i] = '\0'; i--;
23
		tagparam[i] = '\0'; i--;
23
 
24
 
24
		//find VAL start and copy
25
		//find VAL start and copy
25
		i = strrchr(#tagparam, quotes);
26
		i = strrchr(#tagparam, quotes);
26
		strlcpy(#val, #tagparam + i, sizeof(val));
27
		strlcpy(#val, #tagparam + i, sizeof(val)-1);
27
		tagparam[i] = '\0'; i--;
28
		tagparam[i] = '\0'; i--;
28
 
29
 
29
		//find ATTR end
30
		//find ATTR end
30
		while (i > 0) && (tagparam[i] != '=') i--;
31
		while (i > 0) && (tagparam[i] != '=') i--;
31
		tagparam[i+1] = '\0';
32
		tagparam[i+1] = '\0';
32
	}
33
	}
33
	else
34
	else
34
	{
35
	{
35
		//find VAL end
36
		//find VAL end
36
		//already have
37
		//already have
37
 
38
 
38
		//find VAL start and copy
39
		//find VAL start and copy
39
		while (i > 0) && (tagparam[i] != '=') i--;
40
		while (i > 0) && (tagparam[i] != '=') i--;
40
		i++;
41
		i++;
41
		strlcpy(#val, #tagparam + i, sizeof(val));
42
		strlcpy(#val, #tagparam + i, sizeof(val)-1);
42
		tagparam[i] = '\0';
43
		// tagparam[i] = '\0';
43
 
44
 
44
		//find ATTR end
45
		//find ATTR end
45
		//already have
46
		//already have
46
	}
47
	}
47
 
48
 
48
	//find ATTR start and copy
49
	//find ATTR start and copy
49
	while (i>0) && (!__isWhite(tagparam[i])) i--;
50
	while (i>0) && (!__isWhite(tagparam[i])) i--;
50
	strlcpy(#attr, #tagparam + i + 1, sizeof(attr));
51
	strlcpy(#attr, #tagparam + i + 1, sizeof(attr)-1);
51
	tagparam[i] = '\0';
52
	tagparam[i] = '\0';
-
 
53
 
-
 
54
	//fix case: src=./images/KolibriOS_logo2.jpg?sid=e8ece8b38b
-
 
55
	i = strchr(#attr,'=');
-
 
56
	if (!quotes) && (i) {
-
 
57
		strlcpy(#val, i+1, sizeof(val)-1);
-
 
58
		ESBYTE[i+1] = '\0';
-
 
59
	}
52
 
60
 
53
	strlwr(#attr);
61
	strlwr(#attr);
54
 
62
 
55
	if (debug_mode) {
63
	if (debug_mode) {
56
		if (quotes) {
-
 
57
			debug("quote: "); debugch(quotes); debugln(" ");
64
		debug("val: "); debugln(#val);
58
		}
-
 
59
		else {
-
 
60
			debugln("unquoted text");
65
		debug("attr: "); debugln(#attr);
61
		}
-
 
62
		sprintf(#param, "val: %s\nattr: %s\n\n", #val, #attr);
-
 
63
		debug(#param);		
66
		debugln(" ");
64
	}
67
	}
65
 
68
 
66
	return true;
69
	return true;
67
}
70
}