Rev 7756 | 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[5000]; |
7752 | leency | 6 | bool opened; |
7 | collection attributes; |
||
8 | collection values; |
||
9 | bool is(); |
||
10 | bool reset(); |
||
11 | bool parse_params(); |
||
12 | bool get_next_param(); |
||
13 | dword get_value_of(); |
||
14 | } tag; |
||
15 | |||
7282 | leency | 16 | |
7752 | leency | 17 | { |
18 | if ( !strcmp(#tag.name, _text) ) { |
||
19 | return true; |
||
20 | } else { |
||
21 | return false; |
||
22 | } |
||
23 | } |
||
24 | |||
25 | |||
26 | { |
||
27 | if (!name) return false; |
||
28 | strcpy(#prior, #name); |
||
7756 | leency | 29 | name = NULL; |
7752 | leency | 30 | opened = true; |
31 | attributes.drop(); |
||
32 | values.drop(); |
||
33 | return true; |
||
34 | } |
||
35 | |||
36 | |||
37 | { |
||
38 | bool result = false; |
||
39 | if (!name) return false; |
||
40 | if (debug_mode) { |
||
7282 | leency | 41 | debugln(" "); |
7752 | leency | 42 | debugln(" "); |
43 | debug("tag: "); debugln(#name); |
||
44 | debug("params: "); debugln(#params); |
||
45 | debugln(" "); |
||
46 | } |
||
7282 | leency | 47 | while (get_next_param()) { |
7752 | leency | 48 | result = true; |
49 | 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 | }; |
||
55 | return result; |
||
56 | } |
||
57 | |||
7282 | leency | 58 | |
7752 | leency | 59 | { |
60 | byte quotes = NULL; |
||
61 | int i; |
||
62 | unsigned char val[4000]; |
||
63 | unsigned char attr[4000]; |
||
64 | |||
7282 | leency | 65 | |
7752 | leency | 66 | |
67 | |||
68 | if (params[i] == '/') i--; |
||
69 | while (i>0) && (__isWhite(params[i])) i--; |
||
70 | |||
7282 | leency | 71 | |
7752 | leency | 72 | { |
7282 | leency | 73 | //remove quotes |
7752 | leency | 74 | quotes = params[i]; |
75 | params[i] = EOS; |
||
76 | i--; |
||
77 | |||
7282 | leency | 78 | |
79 | i = strrchr(#params, quotes); |
||
7752 | leency | 80 | strlcpy(#val, #params + i, sizeof(val)-1); |
81 | params[i] = EOS; |
||
82 | i--; |
||
83 | |||
7282 | leency | 84 | |
85 | while (i > 0) && (params[i] != '=') i--; |
||
7752 | leency | 86 | params[i+1] = EOS; |
87 | } |
||
7282 | leency | 88 | else |
89 | { |
||
90 | //find VAL start and copy |
||
91 | while (i > 0) && (params[i] != '=') i--; |
||
7752 | leency | 92 | i++; |
7282 | leency | 93 | strlcpy(#val, #params + i, sizeof(val)-1); |
7752 | leency | 94 | |
7282 | leency | 95 | |
7752 | leency | 96 | } |
7282 | leency | 97 | |
98 | |||
99 | while (i>0) && (!__isWhite(params[i])) i--; |
||
7752 | leency | 100 | strlcpy(#attr, #params + i + 1, sizeof(attr)-1); |
101 | strlwr(#attr); |
||
102 | params[i] = '\0'; |
||
103 | |||
7750 | leency | 104 | |
105 | i = strchr(#attr,'='); |
||
106 | if (!quotes) && (i) { |
||
107 | strlcpy(#val, i+1, sizeof(val)-1); |
||
108 | ESBYTE[i+1] = '\0'; |
||
109 | } |
||
110 | |||
7282 | leency | 111 | |
7752 | leency | 112 | values.add(#val); |
113 | |||
7282 | leency | 114 | |
115 | } |
||
116 | |||
117 | |||
7752 | leency | 118 | { |
119 | int pos = attributes.get_pos_by_name(_attr_name); |
||
120 | if (pos == -1) { |
||
121 | return 0; |
||
122 | } else { |
||
123 | return values.get(pos); |
||
124 | } |
||
125 | } |
||
126 |