Rev 8500 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8500 | Rev 9089 | ||
---|---|---|---|
Line 1... | Line -... | ||
1 | struct _tag |
- | |
2 | { |
1 | struct _tag |
3 | char name[32]; |
2 | { |
4 | char prior[32]; |
3 | char name[32]; |
5 | bool opened; |
4 | char prior[32]; |
6 | collection attributes; |
5 | bool opened; |
Line 8... | Line 7... | ||
8 | dword value; |
7 | collection values; |
9 | dword number; |
8 | dword value; |
10 | bool is(); |
9 | dword number; |
11 | bool parse(); |
10 | bool is(); |
12 | void debug_tag(); |
11 | bool parse(); |
13 | dword get_next_param(); |
- | |
14 | dword get_value_of(); |
12 | dword get_next_param(); |
15 | signed get_number_of(); |
13 | dword get_value_of(); |
16 | } tag=0; |
14 | signed get_number_of(); |
17 | 15 | } tag=0; |
|
Line 18... | Line 16... | ||
18 | bool _tag::is(dword _text) |
16 | |
19 | { |
17 | bool _tag::is(dword _text) |
20 | if ( !strcmp(#name, _text) ) { |
18 | { |
21 | return true; |
- | |
22 | } else { |
- | |
23 | return false; |
- | |
24 | } |
- | |
25 | } |
19 | return streq(#name, _text); |
Line 26... | Line 20... | ||
26 | 20 | } |
|
27 | bool _tag::parse(dword _bufpos, bufend) |
21 | |
28 | { |
22 | bool _tag::parse(dword _bufpos, bufend) |
Line 61... | Line 55... | ||
61 | 55 | } |
|
Line 62... | Line 56... | ||
62 | closepos = strchr(bufpos, '>'); |
56 | |
63 | whitepos = strchrw(bufpos, bufend-bufpos); |
57 | closepos = strchr(bufpos, '>'); |
Line 64... | Line -... | ||
64 | - | ||
65 | if (debug_mode) { |
- | |
66 | if (!closepos) debugln("null closepos"); |
- | |
67 | if (!whitepos) debugln("null whitepos"); |
- | |
68 | } |
- | |
69 | 58 | whitepos = strchrw(bufpos, bufend-bufpos); |
|
70 | if (!whitepos) || (whitepos > closepos) { |
59 | |
71 | //no param |
60 | if (!whitepos) || (whitepos > closepos) { |
72 | strncpy(#name, bufpos, math.min(closepos - bufpos, sizeof(tag.name))); |
- | |
73 | debug_tag(); |
61 | //no param |
74 | bufpos = closepos; |
62 | strncpy(#name, bufpos, math.min(closepos - bufpos, sizeof(tag.name))); |
75 | } else { |
63 | bufpos = closepos; |
76 | //we have param |
64 | } else { |
77 | while (chrlnum(whitepos, '\"', closepos - whitepos)%2) { //alt="Next>>" |
- | |
78 | /* |
- | |
79 | openpos = strchr(closepos+1, '<'); |
- | |
80 | closepos = strchr(closepos+1, '>'); |
- | |
81 | if (openpos) && (openpos < closepos) { |
- | |
82 | closepos = openpos - 1; |
- | |
83 | break; |
- | |
84 | } |
- | |
85 | */ |
65 | //we have param |
86 | if (!openpos = strchr(closepos+1, '<')) break; |
66 | while (chrlnum(whitepos, '\"', closepos - whitepos)%2) { //alt="Next>>" |
87 | if (openpos < strchr(closepos+1, '>')) break; |
67 | if (!openpos = strchr(closepos+1, '<')) break; |
88 | if (!closepos = EAX) {closepos = bufend;break;} |
68 | if (openpos < strchr(closepos+1, '>')) break; |
89 | } |
69 | if (!closepos = EAX) {closepos = bufend;break;} |
90 | strncpy(#name, bufpos, math.min(whitepos - bufpos, sizeof(tag.name))); |
- | |
91 | debug_tag(); |
70 | } |
Line 92... | Line 71... | ||
92 | bufpos = closepos; |
71 | strncpy(#name, bufpos, math.min(whitepos - bufpos, sizeof(tag.name))); |
93 | 72 | bufpos = closepos; |
|
94 | params = malloc(closepos - whitepos + 1); |
- | |
95 | strncpy(params, whitepos, closepos - whitepos); |
73 | |
96 | if (debug_mode) { debug("params: "); debugln(params+1); } |
74 | params = malloc(closepos - whitepos + 1); |
97 | paramsend = params + closepos - whitepos; |
75 | strncpy(params, whitepos, closepos - whitepos); |
98 | while (paramsend = get_next_param(params, paramsend-1)); |
76 | paramsend = params + closepos - whitepos; |
Line 118... | Line 96... | ||
118 | ESDWORD[_bufpos] = bufpos; |
96 | _RET: |
119 | return retok; |
97 | ESDWORD[_bufpos] = bufpos; |
120 | } |
98 | return retok; |
121 | 99 | } |
|
Line 122... | Line -... | ||
122 | void _tag::debug_tag() |
- | |
123 | { |
- | |
124 | if (debug_mode) { |
- | |
125 | debugch('<'); |
- | |
126 | if (!opened) debugch('/'); |
- | |
127 | debug(#name); |
- | |
128 | debugln(">"); |
- | |
129 | } |
- | |
130 | } |
- | |
131 | - | ||
132 | dword _tag::get_next_param(dword ps, pe) |
100 | |
133 | { |
101 | dword _tag::get_next_param(dword ps, pe) |
134 | // "ps" - param start |
102 | { |
135 | // "pe" - param end |
103 | // "ps" - param start |
136 | // "q" - quote char |
104 | // "pe" - param end |
Line 187... | Line 155... | ||
187 | 155 | strrtrim(val); |
|
Line 188... | Line 156... | ||
188 | attributes.add(attr); |
156 | |
189 | values.add(val); |
157 | attributes.add(attr); |
Line 190... | Line -... | ||
190 | - | ||
191 | if (debug_mode) { |
- | |
192 | debug("atr: "); debugln(attr); |
- | |
193 | debug("val: "); debugln(val); |
- | |
194 | debugch('\n'); |
- | |
195 | } |
- | |
196 | 158 | values.add(val); |
|
197 | if (pe==ps) return NULL; |
159 | |
198 | return pe; |
160 | if (pe==ps) return NULL; |
Line 199... | Line 161... | ||
199 | } |
161 | return pe; |
Line 211... | Line 173... | ||
211 | 173 | } |
|
Line 212... | Line 174... | ||
212 | signed _tag::get_number_of(dword _attr_name) |
174 | |
213 | { |
175 | signed _tag::get_number_of(dword _attr_name) |
214 | if (get_value_of(_attr_name)) { |
176 | { |
215 | number = atoi(tag.value); |
177 | if (get_value_of(_attr_name)) { |
216 | } else { |
178 | number = atoi(value); |
217 | number = 0; |
179 | } else { |
218 | } |
180 | number = 0; |
219 | return number; |
181 | } |
220 | }>');>>'))>>'); |
182 | return number; |