Rev 6378 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6216 | leency | 1 | struct _tag { |
2 | dword start; |
||
3 | dword name; |
||
4 | dword param[10]; |
||
5 | dword value[10]; |
||
6 | void parce(); |
||
7 | int nameis(); |
||
8 | void clear(); |
||
9 | }; |
||
10 | |||
11 | void _tag::parce() |
||
12 | { |
||
13 | dword o = name = start; |
||
14 | while (ESBYTE[o]!=' ') && (ESBYTE[o]) o++; //searching for a space after tag name |
||
15 | ESBYTE[o] = '\0'; |
||
16 | strlwr(name); |
||
17 | } |
||
18 | |||
19 | int _tag::nameis(dword _in_tag_name) |
||
20 | { |
||
21 | if (name) && (strcmp(_in_tag_name, name)==0) return true; |
||
22 | return false; |
||
23 | } |
||
24 | |||
25 | void _tag::clear() |
||
26 | { |
||
27 | start=name=0; |
||
28 | } |
||
29 | |||
30 | |||
31 | /* |
||
32 | unsigned int GetNextParam() |
||
33 | { |
||
34 | byte kavichki=0; |
||
35 | int i = strlen(#tagparam) - 1; |
||
36 | |||
37 | if (!tagparam) return 0; |
||
38 | |||
39 | WHILE((i > 0) && ((tagparam[i] == '"') || (tagparam[i] == ' ') || (tagparam[i] == '\'') || (tagparam[i] == '/'))) |
||
40 | { |
||
41 | IF (tagparam[i] == '"') || (tagparam[i] == '\'') kavichki=tagparam[i]; |
||
42 | tagparam[i] = 0x00; |
||
43 | i--; |
||
44 | } |
||
45 | |||
46 | if (kavichki) |
||
47 | { |
||
48 | i=strrchr(#tagparam, kavichki); |
||
49 | strlcpy(#val, #tagparam + i, sizeof(val)); |
||
50 | } |
||
51 | else |
||
52 | { |
||
53 | WHILE((i > 0) && (tagparam[i] <>'=')) i--; //i=strrchr(#tagparam, '=')+1; |
||
54 | i++; |
||
55 | strlcpy(#val, #tagparam + i, sizeof(val)); |
||
56 | |||
57 | WHILE (val[0] == ' ') strcpy(#val, #val+1); |
||
58 | } |
||
59 | tagparam[i] = 0x00; |
||
60 | |||
61 | FOR ( ; ((tagparam[i] <>' ') && (i > 0); i--) |
||
62 | { |
||
63 | IF (tagparam[i] == '=') //äåðçêàÿ çàãëóøêà |
||
64 | tagparam[i + 1] = 0x00; |
||
65 | } |
||
66 | strlcpy(#attr, #tagparam + i + 1, sizeof(attr)); |
||
67 | tagparam[i] = 0x00; |
||
68 | strlwr(#attr); |
||
69 | return 1; |
||
70 | } |
||
71 | */ |
||
72 | |||
73 | // |
||
74 | // STYLE |
||
75 | // |
||
76 | |||
77 | struct _style { |
||
78 | bool b, u, i, s; |
||
79 | bool h1, h2, h3, h4, h5, h6; |
||
80 | bool a; |
||
81 | bool pre; |
||
82 | bool ignore; |
||
83 | dword color; |
||
84 | void clear(); |
||
85 | } style; |
||
86 | |||
87 | void _style::clear() |
||
88 | { |
||
89 | b=u=i=s=0; |
||
90 | h1=h2=h3=h4=h5=h6=0; |
||
91 | a=0; |
||
92 | pre=0; |
||
93 | ignore=0; |
||
94 | color=0; |
||
95 | } |
||
96 | |||
97 | |||
98 | // |
||
99 | // TEXT |
||
100 | // |
||
101 | |||
102 | struct _text { |
||
103 | dword start; |
||
6375 | guillem | 104 | char str[7]; |
6216 | leency | 105 | int x, y; |
6378 | guillem | 106 | void fixSpecial(dword text); |
6375 | guillem | 107 | }; |
108 | |||
109 | |||
110 | // unicode conversion for special characters |
||
111 | char *unicode_tags[]={ |
||
112 | "nbsp", " ", |
||
113 | "#38", " ", |
||
114 | "#160", " ", |
||
115 | |||
6378 | guillem | 116 | "ntilde", "n", // spanish n special ñ |
117 | "#224", "à", // spanish a with grove accent 'à' |
||
118 | "#241", "n", // spanish symbol |
||
6375 | guillem | 119 | |
120 | "copy", "(c)", |
||
121 | "#169", "(c)", |
||
122 | |||
123 | "trade", "[TM]", |
||
124 | |||
125 | "reg", "(r)", |
||
126 | "#174", "(r)", |
||
127 | |||
128 | "bdquo", ",,", |
||
129 | |||
130 | "amp", "&", |
||
131 | "#38", "&", |
||
132 | |||
133 | "lt", "<", |
||
134 | "#60", "<", |
||
135 | |||
136 | "gt", ">", |
||
137 | "#62", ">", |
||
138 | |||
139 | "minus", "-", |
||
140 | "ndash", "-", |
||
141 | "mdash", "-", //-- |
||
142 | "#8722", "-", |
||
143 | "#8211", "-", |
||
144 | "#151", "-", |
||
145 | "#149", "-", |
||
146 | |||
147 | "rsquo", "'", |
||
148 | "#39", "'", |
||
149 | "#96", "'", |
||
150 | "#8217", "'", |
||
151 | |||
152 | "quot", "\"", |
||
153 | "#34", "\"", |
||
154 | "ldquo", "\"", |
||
155 | "rdquo", "\"", |
||
156 | "#8222", "\"", |
||
157 | "#8221", "\"", |
||
158 | |||
159 | "laquo", "<<", |
||
160 | "#171", "<<", |
||
161 | "raquo", ">>", |
||
162 | "#187", ">>", |
||
163 | |||
164 | "uarr", "\24", |
||
165 | "darr", "\25", |
||
166 | "rarr", "\26", |
||
167 | "larr", "\27", |
||
168 | |||
169 | "#1028", "\242", |
||
170 | "#1030", "I", |
||
171 | "#1031", "\244", |
||
172 | |||
173 | "#8470", "N", |
||
174 | "bull", "-", //âîîáùå çäåñü òî÷êà |
||
175 | "percnt","%", |
||
176 | |||
6378 | guillem | 177 | 0}; |
6375 | guillem | 178 | |
6378 | guillem | 179 | // function to be called to fix the special symbols |
180 | void _text::fixSpecial(dword text) { |
||
181 | byte ch; |
||
182 | int i , j, z; |
||
183 | dword aux; |
||
184 | dword text2 = text; |
||
185 | loop () { |
||
186 | ch = ESBYTE[text]; |
||
187 | if (!ch) return; |
||
188 | if (ch=='&') { |
||
189 | i = 0; |
||
190 | j = 0; |
||
191 | text++; |
||
192 | while ( i < 7) { |
||
193 | ch = ESBYTE[text]; |
||
194 | if (ch == ';') { |
||
195 | z = get_symbol(#str); |
||
196 | //debugval("z: ", z); |
||
6383 | guillem | 197 | if (z == -1) { // not found |
198 | ch = ' '; |
||
199 | } |
||
200 | else { // tag found |
||
201 | aux = unicode_tags[z]; |
||
202 | strtrim(aux); |
||
203 | debugln(aux); |
||
6378 | guillem | 204 | ch = ESBYTE[aux]; |
6383 | guillem | 205 | // copy the special symbol found |
206 | while (ch) { |
||
207 | ESBYTE[text2] = ch; |
||
208 | aux++; |
||
209 | text2++; |
||
210 | ch = ESBYTE[aux]; |
||
211 | } |
||
212 | ch = ESBYTE[text2]; |
||
6378 | guillem | 213 | } |
6383 | guillem | 214 | // clean the old symbol |
6378 | guillem | 215 | while (ch != ';') { |
6383 | guillem | 216 | ESBYTE[text2] = ' ';// should be (char) 0; |
6378 | guillem | 217 | text2++; |
218 | ch = ESBYTE[text2]; |
||
219 | } |
||
6383 | guillem | 220 | ESBYTE[text2] = ' '; // should be '' or char 0 |
6378 | guillem | 221 | break; |
222 | } |
||
223 | str[i] = ch; |
||
224 | if (!ch) return; |
||
225 | text++; |
||
226 | i++; |
||
227 | } |
||
6383 | guillem | 228 | for (i=0; i < 7; i++) str[i] = 0; // clean str |
6378 | guillem | 229 | } |
230 | text++; |
||
231 | text2++; |
||
232 | } |
||
233 | } |
||
234 | |||
235 | |||
236 | |||
6383 | guillem | 237 | // function to look for the conversion of special characters |
238 | // if not found--> return -1 |
||
6378 | guillem | 239 | int get_symbol(char *str2) { |
240 | int i,j; |
||
241 | //debugln(#str2); |
||
6377 | guillem | 242 | for (i=0; unicode_tags[i]!=0; i+=2) { |
6378 | guillem | 243 | if (strcmp(str2, unicode_tags[i]) == 0) { |
6383 | guillem | 244 | return (i+1); |
6375 | guillem | 245 | } |
246 | } |
||
6383 | guillem | 247 | return -1; |
6375 | guillem | 248 | }>>", |
249 | |||
250 | |||
251 |