Subversion Repositories Kolibri OS

Rev

Rev 6375 | 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;
6375 guillem 106
	void fixSpecial();
107
};
108
 
109
// function to be called to fix the special symbols
110
void _text::fixSpecial() {
111
	get_char(start);
112
	clean_str();
113
}
114
 
115
// function that traverse the text in sarch for a special
116
// character starting with &
117
// if found, try to look for the conversion
118
void get_char(dword text) {
119
	byte ch;
120
	int i = 0, j = 0;
121
	dword text2 = text;
122
	loop () {
123
		ch = ESBYTE[text];
124
		if (!ch) return;
125
		if (ch=='&') {
126
			i = 0;
127
			text++;
128
			while ( i < 7)  {
129
				ch = ESBYTE[text];
130
				if (ch == ';') {
131
					ESBYTE[text2] = get_symbol();
132
					while (j < i) {
133
						j++;
134
						text2++;
135
						ESBYTE[text2] = 0;
136
					}
137
					//debugln(#str);
138
					break;
139
				}
140
				str[i] = ch;
141
				if (!ch) return;
142
				text++;
143
				i++;
144
			}
145
		}
146
		text++;
147
		text2++;
148
	}
149
}
150
 
151
// unicode conversion for special characters
152
char *unicode_tags[]={
153
"nbsp",  " ",
154
"#38",   " ",
155
"#160",  " ",
156
 
157
"ntilde", "ñ", // spanish n special ñ
6376 guillem 158
"#224",  0xC3A0, // spanish a with grove accent 'à'
159
"#241",  0xC3B1, // spanish symbol
6375 guillem 160
 
161
"copy",  "(c)",
162
"#169",  "(c)",
163
 
164
"trade", "[TM]",
165
 
166
"reg",   "(r)",
167
"#174",  "(r)",
168
 
169
"bdquo", ",,",
170
 
171
"amp",   "&",
172
"#38",   "&",
173
 
174
"lt",    "<",
175
"#60",   "<",
176
 
177
"gt",    ">",
178
"#62",   ">",
179
 
180
"minus", "-",
181
"ndash", "-",
182
"mdash", "-", //--
183
"#8722", "-",
184
"#8211", "-",
185
"#151",  "-",
186
"#149",  "-",
187
 
188
"rsquo", "'",
189
"#39",   "'",
190
"#96",   "'",
191
"#8217", "'",
192
 
193
"quot",  "\"",
194
"#34",   "\"",
195
"ldquo", "\"",
196
"rdquo", "\"",
197
"#8222", "\"",
198
"#8221", "\"",
199
 
200
"laquo", "<<",
201
"#171",  "<<",
202
"raquo", ">>",
203
"#187",  ">>",
204
 
205
"uarr",  "\24",
206
"darr",  "\25",
207
"rarr",  "\26",
208
"larr",  "\27",
209
 
210
"#1028", "\242",
211
"#1030", "I",
212
"#1031", "\244",
213
 
214
"#8470", "N",
215
"bull",  "-", //âîîáùå çäåñü òî÷êà
216
"percnt","%",
217
 
218
0};
219
 
220
// function to look for the conversion od special characters
221
// if not found--> return 0
222
char get_symbol() {
223
	int i;
224
	debugln(#str);
225
	for (i=0; unicode_tags[i]!=0; i+=2) {}
226
		if (strcmp(#str, unicode_tags[i]) == 0) {
227
			//debugval("i: ", i);
228
			return unicode_tags[i+1]);
229
		}
230
	}
231
	return 0;
232
}
233
 
234
// function to clean string str
235
void clean_str() {
236
	int i;
237
	for (i=0; i < 7; i++) {
238
		str[i] = 0;
239
	}
240
}
241
 
242