Rev 8444 | Rev 8490 | 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, "%s>", #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 | dword val; |
||
8445 | leency | 124 | dword attr; |
8443 | leency | 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 | val = pe; |
8445 | leency | 139 | pe--; |
140 | ESBYTE[pe] = '\0'; |
||
8440 | leency | 141 | |
7282 | leency | 142 | |
143 | while (pe > ps) && (ESBYTE[pe] != '=') pe--; |
||
8440 | leency | 144 | ESBYTE[pe] = '\0'; |
8444 | leency | 145 | } |
7282 | leency | 146 | else |
147 | { |
||
148 | //find VAL start and copy |
||
149 | while (pe > ps) && (ESBYTE[pe] != '=') pe--; |
||
8440 | leency | 150 | val = pe+1; |
8445 | leency | 151 | ESBYTE[pe] = '\0'; |
8444 | leency | 152 | //already have ATTR end |
7752 | leency | 153 | } |
7282 | leency | 154 | |
155 | |||
156 | while (pe>ps) && (!__isWhite(ESBYTE[pe])) pe--; |
||
8440 | leency | 157 | attr = pe + 1; |
8443 | leency | 158 | ESBYTE[pe] = '\0'; |
8440 | leency | 159 | |
8445 | leency | 160 | |
161 | // Exchange '=' and '\0' position. |
||
162 | // attr: src=./images/logo?sid => src |
||
163 | // val: e8ece8b38b => ./images/logo?sid=e8ece8b38b |
||
164 | fixeq = strchr(attr,'='); |
||
8443 | leency | 165 | if (!q) && (fixeq) { |
8440 | leency | 166 | ESBYTE[val-1] >< ESBYTE[fixeq]; |
8445 | leency | 167 | val = fixeq+1; |
168 | } |
||
7750 | leency | 169 | strlwr(attr); |
8443 | leency | 170 | strrtrim(val); |
8445 | leency | 171 | |
7282 | leency | 172 | |
8443 | leency | 173 | values.add(val); |
8445 | leency | 174 | |
7282 | leency | 175 | |
8439 | leency | 176 | debug("atr: "); debugln(attr); |
8443 | leency | 177 | debug("val: "); debugln(val); |
8445 | leency | 178 | debugch('\n'); |
8439 | leency | 179 | } |
180 | |||
181 | |||
8440 | leency | 182 | return pe; |
183 | } |
||
7282 | leency | 184 | |
185 | |||
7752 | leency | 186 | { |
187 | int pos = attributes.get_pos_by_name(_attr_name); |
||
188 | if (pos == -1) { |
||
189 | value = 0; |
||
8439 | leency | 190 | } else { |
7752 | leency | 191 | value = values.get(pos); |
8439 | leency | 192 | } |
7752 | leency | 193 | return value; |
8439 | leency | 194 | }>');>> |
7752 | leency | 195 |