Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Annotation of /trunk/src/translations.c
Parent Directory
|
Revision Log
Revision 1410 -
(hide annotations)
(download)
(as text)
Fri Jun 21 15:48:19 2013 UTC (11 years, 8 months ago) by amb
File MIME type: text/x-csrc
File size: 41958 byte(s)
Fri Jun 21 15:48:19 2013 UTC (11 years, 8 months ago) by amb
File MIME type: text/x-csrc
File size: 41958 byte(s)
Rename the functions for unbuffered file access to make this clear.
1 | amb | 361 | /*************************************** |
2 | Load the translations from a file and the functions for handling them. | ||
3 | |||
4 | Part of the Routino routing software. | ||
5 | ******************/ /****************** | ||
6 | amb | 1384 | This file Copyright 2010-2013 Andrew M. Bishop |
7 | amb | 361 | |
8 | This program is free software: you can redistribute it and/or modify | ||
9 | it under the terms of the GNU Affero General Public License as published by | ||
10 | the Free Software Foundation, either version 3 of the License, or | ||
11 | (at your option) any later version. | ||
12 | |||
13 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU Affero General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU Affero General Public License | ||
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | ***************************************/ | ||
21 | |||
22 | |||
23 | #include <stdio.h> | ||
24 | #include <string.h> | ||
25 | #include <stdlib.h> | ||
26 | |||
27 | amb | 449 | #include "files.h" |
28 | amb | 361 | #include "translations.h" |
29 | #include "xmlparse.h" | ||
30 | |||
31 | |||
32 | amb | 486 | /* Global variables - default English values - Must not require any UTF-8 encoding */ |
33 | amb | 361 | |
34 | amb | 893 | char *translate_raw_copyright_creator[2]={"Creator","Routino - http://www.routino.org/"}; |
35 | char *translate_raw_copyright_source[2] ={NULL,NULL}; | ||
36 | char *translate_raw_copyright_license[2]={NULL,NULL}; | ||
37 | amb | 361 | |
38 | amb | 893 | char *translate_xml_copyright_creator[2]={"Creator","Routino - http://www.routino.org/"}; |
39 | char *translate_xml_copyright_source[2] ={NULL,NULL}; | ||
40 | char *translate_xml_copyright_license[2]={NULL,NULL}; | ||
41 | amb | 375 | |
42 | amb | 925 | char *translate_xml_heading[9] ={"South","South-West","West","North-West","North","North-East","East","South-East","South"}; |
43 | char *translate_xml_turn[9] ={"Very sharp left","Sharp left","Left","Slight left","Straight on","Slight right","Right","Sharp right","Very sharp right"}; | ||
44 | char *translate_xml_ordinal[10]={"First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth"}; | ||
45 | amb | 361 | |
46 | amb | 1174 | char *translate_raw_highway[Highway_Count]={"","motorway","trunk road","primary road","secondary road","tertiary road","unclassified road","residential road","service road","track","cycleway","path","steps","ferry"}; |
47 | amb | 361 | |
48 | amb | 893 | char *translate_xml_route_shortest="Shortest"; |
49 | char *translate_xml_route_quickest="Quickest"; | ||
50 | |||
51 | amb | 1384 | char *translate_html_waypoint ="<span class='w'>Waypoint</span>"; /* when reading XML translations file span is added */ |
52 | amb | 925 | char *translate_html_junction ="Junction"; |
53 | char *translate_html_roundabout="Roundabout"; | ||
54 | amb | 378 | |
55 | amb | 925 | char *translate_html_title ="%s Route"; |
56 | amb | 1384 | char *translate_html_start[2] ={"Start" ,"At %s, head %s"}; |
57 | char *translate_html_node[2] ={"At" ,"%s, go %s heading %s"}; | ||
58 | char *translate_html_rbnode[2] ={"Leave" ,"%s, take the %s exit heading %s"}; | ||
59 | amb | 378 | char *translate_html_segment[2]={"Follow","%s for %.3f km, %.1f min"}; |
60 | amb | 1384 | char *translate_html_stop[2] ={"Stop" ,"At %s"}; |
61 | char *translate_html_total[2] ={"Total" ,"%.1f km, %.0f minutes"}; | ||
62 | amb | 378 | |
63 | amb | 1384 | char *translate_gpx_desc ="%s route between 'start' and 'finish' waypoints"; |
64 | char *translate_gpx_name ="%s route"; | ||
65 | char *translate_gpx_step ="%s on '%s' for %.3f km, %.1f min"; | ||
66 | char *translate_gpx_final="Total Journey %.1f km, %.0f minutes"; | ||
67 | amb | 411 | |
68 | amb | 925 | char *translate_gpx_start ="START"; |
69 | char *translate_gpx_inter ="INTER"; | ||
70 | char *translate_gpx_trip ="TRIP"; | ||
71 | amb | 361 | char *translate_gpx_finish="FINISH"; |
72 | |||
73 | |||
74 | /* Local variables */ | ||
75 | |||
76 | /*+ The language that is to be stored. +*/ | ||
77 | static const char *store_lang=NULL; | ||
78 | |||
79 | /*+ This current language is to be stored. +*/ | ||
80 | static int store=0; | ||
81 | |||
82 | /*+ The chosen language has been stored. +*/ | ||
83 | static int stored=0; | ||
84 | |||
85 | |||
86 | /* The XML tag processing function prototypes */ | ||
87 | |||
88 | amb | 373 | //static int xmlDeclaration_function(const char *_tag_,int _type_,const char *version,const char *encoding); |
89 | //static int RoutinoTranslationsType_function(const char *_tag_,int _type_); | ||
90 | amb | 1205 | static int LanguageType_function(const char *_tag_,int _type_,const char *lang); |
91 | amb | 1204 | //static int CopyrightType_function(const char *_tag_,int _type_); |
92 | static int TurnType_function(const char *_tag_,int _type_,const char *direction,const char *string); | ||
93 | static int HeadingType_function(const char *_tag_,int _type_,const char *direction,const char *string); | ||
94 | static int OrdinalType_function(const char *_tag_,int _type_,const char *number,const char *string); | ||
95 | static int HighwayType_function(const char *_tag_,int _type_,const char *type,const char *string); | ||
96 | static int RouteType_function(const char *_tag_,int _type_,const char *type,const char *string); | ||
97 | //static int HTMLType_function(const char *_tag_,int _type_); | ||
98 | amb | 373 | //static int GPXType_function(const char *_tag_,int _type_); |
99 | amb | 1204 | static int CopyrightCreatorType_function(const char *_tag_,int _type_,const char *string,const char *text); |
100 | static int CopyrightSourceType_function(const char *_tag_,int _type_,const char *string,const char *text); | ||
101 | static int CopyrightLicenseType_function(const char *_tag_,int _type_,const char *string,const char *text); | ||
102 | static int HTMLWaypointType_function(const char *_tag_,int _type_,const char *type,const char *string); | ||
103 | static int HTMLTitleType_function(const char *_tag_,int _type_,const char *text); | ||
104 | static int HTMLStartType_function(const char *_tag_,int _type_,const char *string,const char *text); | ||
105 | static int HTMLNodeType_function(const char *_tag_,int _type_,const char *string,const char *text); | ||
106 | static int HTMLRBNodeType_function(const char *_tag_,int _type_,const char *string,const char *text); | ||
107 | static int HTMLSegmentType_function(const char *_tag_,int _type_,const char *string,const char *text); | ||
108 | static int HTMLStopType_function(const char *_tag_,int _type_,const char *string,const char *text); | ||
109 | amb | 378 | static int HTMLTotalType_function(const char *_tag_,int _type_,const char *string,const char *text); |
110 | amb | 373 | static int GPXWaypointType_function(const char *_tag_,int _type_,const char *type,const char *string); |
111 | amb | 1204 | static int GPXDescType_function(const char *_tag_,int _type_,const char *text); |
112 | static int GPXNameType_function(const char *_tag_,int _type_,const char *text); | ||
113 | static int GPXStepType_function(const char *_tag_,int _type_,const char *text); | ||
114 | static int GPXFinalType_function(const char *_tag_,int _type_,const char *text); | ||
115 | amb | 361 | |
116 | |||
117 | amb | 1204 | /* The XML tag definitions (forward declarations) */ |
118 | amb | 361 | |
119 | amb | 1204 | static xmltag xmlDeclaration_tag; |
120 | static xmltag RoutinoTranslationsType_tag; | ||
121 | amb | 1205 | static xmltag LanguageType_tag; |
122 | amb | 1204 | static xmltag CopyrightType_tag; |
123 | static xmltag TurnType_tag; | ||
124 | static xmltag HeadingType_tag; | ||
125 | static xmltag OrdinalType_tag; | ||
126 | static xmltag HighwayType_tag; | ||
127 | static xmltag RouteType_tag; | ||
128 | static xmltag HTMLType_tag; | ||
129 | static xmltag GPXType_tag; | ||
130 | static xmltag CopyrightCreatorType_tag; | ||
131 | static xmltag CopyrightSourceType_tag; | ||
132 | static xmltag CopyrightLicenseType_tag; | ||
133 | static xmltag HTMLWaypointType_tag; | ||
134 | static xmltag HTMLTitleType_tag; | ||
135 | static xmltag HTMLStartType_tag; | ||
136 | static xmltag HTMLNodeType_tag; | ||
137 | static xmltag HTMLRBNodeType_tag; | ||
138 | static xmltag HTMLSegmentType_tag; | ||
139 | static xmltag HTMLStopType_tag; | ||
140 | static xmltag HTMLTotalType_tag; | ||
141 | static xmltag GPXWaypointType_tag; | ||
142 | static xmltag GPXDescType_tag; | ||
143 | static xmltag GPXNameType_tag; | ||
144 | static xmltag GPXStepType_tag; | ||
145 | static xmltag GPXFinalType_tag; | ||
146 | amb | 375 | |
147 | |||
148 | amb | 1204 | /* The XML tag definition values */ |
149 | |||
150 | /*+ The complete set of tags at the top level. +*/ | ||
151 | static xmltag *xml_toplevel_tags[]={&xmlDeclaration_tag,&RoutinoTranslationsType_tag,NULL}; | ||
152 | |||
153 | /*+ The xmlDeclaration type tag. +*/ | ||
154 | static xmltag xmlDeclaration_tag= | ||
155 | {"xml", | ||
156 | 2, {"version","encoding"}, | ||
157 | NULL, | ||
158 | amb | 375 | {NULL}}; |
159 | |||
160 | amb | 1204 | /*+ The RoutinoTranslationsType type tag. +*/ |
161 | static xmltag RoutinoTranslationsType_tag= | ||
162 | {"routino-translations", | ||
163 | 0, {NULL}, | ||
164 | NULL, | ||
165 | amb | 1205 | {&LanguageType_tag,NULL}}; |
166 | amb | 1204 | |
167 | amb | 1205 | /*+ The LanguageType type tag. +*/ |
168 | static xmltag LanguageType_tag= | ||
169 | amb | 1204 | {"language", |
170 | 1, {"lang"}, | ||
171 | amb | 1205 | LanguageType_function, |
172 | amb | 1204 | {&CopyrightType_tag,&TurnType_tag,&HeadingType_tag,&OrdinalType_tag,&HighwayType_tag,&RouteType_tag,&HTMLType_tag,&GPXType_tag,NULL}}; |
173 | |||
174 | /*+ The CopyrightType type tag. +*/ | ||
175 | static xmltag CopyrightType_tag= | ||
176 | {"copyright", | ||
177 | 0, {NULL}, | ||
178 | NULL, | ||
179 | {&CopyrightCreatorType_tag,&CopyrightSourceType_tag,&CopyrightLicenseType_tag,NULL}}; | ||
180 | |||
181 | amb | 361 | /*+ The TurnType type tag. +*/ |
182 | amb | 367 | static xmltag TurnType_tag= |
183 | amb | 361 | {"turn", |
184 | 2, {"direction","string"}, | ||
185 | amb | 367 | TurnType_function, |
186 | amb | 361 | {NULL}}; |
187 | |||
188 | /*+ The HeadingType type tag. +*/ | ||
189 | amb | 367 | static xmltag HeadingType_tag= |
190 | amb | 361 | {"heading", |
191 | 2, {"direction","string"}, | ||
192 | amb | 367 | HeadingType_function, |
193 | amb | 361 | {NULL}}; |
194 | |||
195 | amb | 925 | /*+ The OrdinalType type tag. +*/ |
196 | static xmltag OrdinalType_tag= | ||
197 | {"ordinal", | ||
198 | 2, {"number","string"}, | ||
199 | OrdinalType_function, | ||
200 | {NULL}}; | ||
201 | |||
202 | amb | 411 | /*+ The HighwayType type tag. +*/ |
203 | static xmltag HighwayType_tag= | ||
204 | {"highway", | ||
205 | 2, {"type","string"}, | ||
206 | HighwayType_function, | ||
207 | {NULL}}; | ||
208 | |||
209 | amb | 378 | /*+ The RouteType type tag. +*/ |
210 | static xmltag RouteType_tag= | ||
211 | {"route", | ||
212 | 2, {"type","string"}, | ||
213 | RouteType_function, | ||
214 | amb | 361 | {NULL}}; |
215 | |||
216 | amb | 1204 | /*+ The HTMLType type tag. +*/ |
217 | static xmltag HTMLType_tag= | ||
218 | {"output-html", | ||
219 | 0, {NULL}, | ||
220 | NULL, | ||
221 | {&HTMLWaypointType_tag,&HTMLTitleType_tag,&HTMLStartType_tag,&HTMLNodeType_tag,&HTMLRBNodeType_tag,&HTMLSegmentType_tag,&HTMLStopType_tag,&HTMLTotalType_tag,NULL}}; | ||
222 | |||
223 | /*+ The GPXType type tag. +*/ | ||
224 | static xmltag GPXType_tag= | ||
225 | {"output-gpx", | ||
226 | 0, {NULL}, | ||
227 | NULL, | ||
228 | {&GPXWaypointType_tag,&GPXDescType_tag,&GPXNameType_tag,&GPXStepType_tag,&GPXFinalType_tag,NULL}}; | ||
229 | |||
230 | /*+ The CopyrightCreatorType type tag. +*/ | ||
231 | static xmltag CopyrightCreatorType_tag= | ||
232 | {"creator", | ||
233 | 2, {"string","text"}, | ||
234 | CopyrightCreatorType_function, | ||
235 | {NULL}}; | ||
236 | |||
237 | /*+ The CopyrightSourceType type tag. +*/ | ||
238 | static xmltag CopyrightSourceType_tag= | ||
239 | {"source", | ||
240 | 2, {"string","text"}, | ||
241 | CopyrightSourceType_function, | ||
242 | {NULL}}; | ||
243 | |||
244 | /*+ The CopyrightLicenseType type tag. +*/ | ||
245 | static xmltag CopyrightLicenseType_tag= | ||
246 | {"license", | ||
247 | 2, {"string","text"}, | ||
248 | CopyrightLicenseType_function, | ||
249 | {NULL}}; | ||
250 | |||
251 | amb | 378 | /*+ The HTMLWaypointType type tag. +*/ |
252 | static xmltag HTMLWaypointType_tag= | ||
253 | {"waypoint", | ||
254 | amb | 361 | 2, {"type","string"}, |
255 | amb | 378 | HTMLWaypointType_function, |
256 | amb | 361 | {NULL}}; |
257 | |||
258 | amb | 378 | /*+ The HTMLTitleType type tag. +*/ |
259 | static xmltag HTMLTitleType_tag= | ||
260 | {"title", | ||
261 | 1, {"text"}, | ||
262 | HTMLTitleType_function, | ||
263 | amb | 361 | {NULL}}; |
264 | |||
265 | amb | 378 | /*+ The HTMLStartType type tag. +*/ |
266 | static xmltag HTMLStartType_tag= | ||
267 | {"start", | ||
268 | 2, {"string","text"}, | ||
269 | HTMLStartType_function, | ||
270 | {NULL}}; | ||
271 | |||
272 | /*+ The HTMLNodeType type tag. +*/ | ||
273 | static xmltag HTMLNodeType_tag= | ||
274 | {"node", | ||
275 | 2, {"string","text"}, | ||
276 | HTMLNodeType_function, | ||
277 | {NULL}}; | ||
278 | |||
279 | amb | 925 | /*+ The HTMLRBNodeType type tag. +*/ |
280 | static xmltag HTMLRBNodeType_tag= | ||
281 | {"rbnode", | ||
282 | 2, {"string","text"}, | ||
283 | HTMLRBNodeType_function, | ||
284 | {NULL}}; | ||
285 | |||
286 | amb | 378 | /*+ The HTMLSegmentType type tag. +*/ |
287 | static xmltag HTMLSegmentType_tag= | ||
288 | {"segment", | ||
289 | 2, {"string","text"}, | ||
290 | HTMLSegmentType_function, | ||
291 | {NULL}}; | ||
292 | |||
293 | /*+ The HTMLStopType type tag. +*/ | ||
294 | static xmltag HTMLStopType_tag= | ||
295 | {"stop", | ||
296 | 2, {"string","text"}, | ||
297 | HTMLStopType_function, | ||
298 | {NULL}}; | ||
299 | |||
300 | /*+ The HTMLTotalType type tag. +*/ | ||
301 | static xmltag HTMLTotalType_tag= | ||
302 | {"total", | ||
303 | 2, {"string","text"}, | ||
304 | HTMLTotalType_function, | ||
305 | {NULL}}; | ||
306 | |||
307 | amb | 1204 | /*+ The GPXWaypointType type tag. +*/ |
308 | static xmltag GPXWaypointType_tag= | ||
309 | {"waypoint", | ||
310 | 2, {"type","string"}, | ||
311 | GPXWaypointType_function, | ||
312 | {NULL}}; | ||
313 | amb | 378 | |
314 | amb | 361 | /*+ The GPXDescType type tag. +*/ |
315 | amb | 367 | static xmltag GPXDescType_tag= |
316 | amb | 361 | {"desc", |
317 | 1, {"text"}, | ||
318 | amb | 367 | GPXDescType_function, |
319 | amb | 361 | {NULL}}; |
320 | |||
321 | /*+ The GPXNameType type tag. +*/ | ||
322 | amb | 367 | static xmltag GPXNameType_tag= |
323 | amb | 361 | {"name", |
324 | 1, {"text"}, | ||
325 | amb | 367 | GPXNameType_function, |
326 | amb | 361 | {NULL}}; |
327 | |||
328 | /*+ The GPXStepType type tag. +*/ | ||
329 | amb | 367 | static xmltag GPXStepType_tag= |
330 | amb | 361 | {"step", |
331 | 1, {"text"}, | ||
332 | amb | 367 | GPXStepType_function, |
333 | amb | 361 | {NULL}}; |
334 | |||
335 | /*+ The GPXFinalType type tag. +*/ | ||
336 | amb | 367 | static xmltag GPXFinalType_tag= |
337 | amb | 361 | {"final", |
338 | 1, {"text"}, | ||
339 | amb | 367 | GPXFinalType_function, |
340 | amb | 361 | {NULL}}; |
341 | |||
342 | |||
343 | /* The XML tag processing functions */ | ||
344 | |||
345 | |||
346 | /*++++++++++++++++++++++++++++++++++++++ | ||
347 | amb | 1204 | The function that is called when the XML declaration is seen |
348 | amb | 375 | |
349 | amb | 1204 | int xmlDeclaration_function Returns 0 if no error occured or something else otherwise. |
350 | amb | 375 | |
351 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
352 | |||
353 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
354 | |||
355 | amb | 1204 | const char *version The contents of the 'version' attribute (or NULL if not defined). |
356 | amb | 375 | |
357 | amb | 1204 | const char *encoding The contents of the 'encoding' attribute (or NULL if not defined). |
358 | amb | 375 | ++++++++++++++++++++++++++++++++++++++*/ |
359 | |||
360 | amb | 1204 | //static int xmlDeclaration_function(const char *_tag_,int _type_,const char *version,const char *encoding) |
361 | //{ | ||
362 | // return(0); | ||
363 | //} | ||
364 | amb | 486 | |
365 | amb | 375 | |
366 | amb | 1204 | /*++++++++++++++++++++++++++++++++++++++ |
367 | The function that is called when the RoutinoTranslationsType XSD type is seen | ||
368 | amb | 893 | |
369 | amb | 1204 | int RoutinoTranslationsType_function Returns 0 if no error occured or something else otherwise. |
370 | amb | 486 | |
371 | amb | 1204 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
372 | amb | 375 | |
373 | amb | 1204 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. |
374 | ++++++++++++++++++++++++++++++++++++++*/ | ||
375 | amb | 375 | |
376 | amb | 1204 | //static int RoutinoTranslationsType_function(const char *_tag_,int _type_) |
377 | //{ | ||
378 | // return(0); | ||
379 | //} | ||
380 | amb | 375 | |
381 | amb | 1204 | |
382 | amb | 375 | /*++++++++++++++++++++++++++++++++++++++ |
383 | amb | 1205 | The function that is called when the LanguageType XSD type is seen |
384 | amb | 375 | |
385 | amb | 1205 | int LanguageType_function Returns 0 if no error occured or something else otherwise. |
386 | amb | 375 | |
387 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
388 | |||
389 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
390 | |||
391 | amb | 1204 | const char *lang The contents of the 'lang' attribute (or NULL if not defined). |
392 | amb | 375 | ++++++++++++++++++++++++++++++++++++++*/ |
393 | |||
394 | amb | 1205 | static int LanguageType_function(const char *_tag_,int _type_,const char *lang) |
395 | amb | 375 | { |
396 | amb | 1204 | static int first=1; |
397 | |||
398 | if(_type_&XMLPARSE_TAG_START) | ||
399 | amb | 375 | { |
400 | amb | 1204 | XMLPARSE_ASSERT_STRING(_tag_,lang); |
401 | amb | 486 | |
402 | amb | 1204 | if(!store_lang && first) |
403 | store=1; | ||
404 | else if(store_lang && !strcmp(store_lang,lang)) | ||
405 | store=1; | ||
406 | else | ||
407 | store=0; | ||
408 | amb | 375 | |
409 | amb | 1204 | first=0; |
410 | } | ||
411 | amb | 893 | |
412 | amb | 1204 | if(_type_&XMLPARSE_TAG_END && store) |
413 | { | ||
414 | store=0; | ||
415 | stored=1; | ||
416 | amb | 375 | } |
417 | |||
418 | return(0); | ||
419 | } | ||
420 | |||
421 | |||
422 | /*++++++++++++++++++++++++++++++++++++++ | ||
423 | amb | 1204 | The function that is called when the CopyrightType XSD type is seen |
424 | amb | 375 | |
425 | amb | 1204 | int CopyrightType_function Returns 0 if no error occured or something else otherwise. |
426 | amb | 375 | |
427 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
428 | |||
429 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
430 | ++++++++++++++++++++++++++++++++++++++*/ | ||
431 | |||
432 | amb | 1204 | //static int CopyrightType_function(const char *_tag_,int _type_) |
433 | //{ | ||
434 | // return(0); | ||
435 | //} | ||
436 | amb | 486 | |
437 | amb | 375 | |
438 | /*++++++++++++++++++++++++++++++++++++++ | ||
439 | amb | 361 | The function that is called when the TurnType XSD type is seen |
440 | |||
441 | amb | 367 | int TurnType_function Returns 0 if no error occured or something else otherwise. |
442 | amb | 363 | |
443 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
444 | |||
445 | amb | 361 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. |
446 | |||
447 | const char *direction The contents of the 'direction' attribute (or NULL if not defined). | ||
448 | |||
449 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
450 | ++++++++++++++++++++++++++++++++++++++*/ | ||
451 | |||
452 | amb | 373 | static int TurnType_function(const char *_tag_,int _type_,const char *direction,const char *string) |
453 | amb | 361 | { |
454 | if(_type_&XMLPARSE_TAG_START && store) | ||
455 | { | ||
456 | amb | 486 | char *xmlstring; |
457 | amb | 361 | int d; |
458 | |||
459 | amb | 774 | XMLPARSE_ASSERT_INTEGER(_tag_,direction); d=atoi(direction); |
460 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,string); |
461 | amb | 361 | |
462 | amb | 363 | d+=4; |
463 | amb | 361 | |
464 | if(d<0 || d>8) | ||
465 | amb | 373 | XMLPARSE_INVALID(_tag_,direction); |
466 | amb | 361 | |
467 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
468 | |||
469 | amb | 893 | translate_xml_turn[d]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
470 | amb | 361 | } |
471 | amb | 363 | |
472 | return(0); | ||
473 | amb | 361 | } |
474 | |||
475 | |||
476 | /*++++++++++++++++++++++++++++++++++++++ | ||
477 | The function that is called when the HeadingType XSD type is seen | ||
478 | |||
479 | amb | 367 | int HeadingType_function Returns 0 if no error occured or something else otherwise. |
480 | amb | 363 | |
481 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
482 | |||
483 | amb | 361 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. |
484 | |||
485 | const char *direction The contents of the 'direction' attribute (or NULL if not defined). | ||
486 | |||
487 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
488 | ++++++++++++++++++++++++++++++++++++++*/ | ||
489 | |||
490 | amb | 373 | static int HeadingType_function(const char *_tag_,int _type_,const char *direction,const char *string) |
491 | amb | 361 | { |
492 | if(_type_&XMLPARSE_TAG_START && store) | ||
493 | { | ||
494 | amb | 486 | char *xmlstring; |
495 | amb | 361 | int d; |
496 | |||
497 | amb | 774 | XMLPARSE_ASSERT_INTEGER(_tag_,direction); d=atoi(direction); |
498 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,string); |
499 | amb | 361 | |
500 | amb | 363 | d+=4; |
501 | amb | 361 | |
502 | if(d<0 || d>8) | ||
503 | amb | 373 | XMLPARSE_INVALID(_tag_,direction); |
504 | amb | 361 | |
505 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
506 | |||
507 | amb | 893 | translate_xml_heading[d]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
508 | amb | 361 | } |
509 | amb | 363 | |
510 | return(0); | ||
511 | amb | 361 | } |
512 | |||
513 | |||
514 | /*++++++++++++++++++++++++++++++++++++++ | ||
515 | amb | 925 | The function that is called when the OrdinalType XSD type is seen |
516 | |||
517 | int OrdinalType_function Returns 0 if no error occured or something else otherwise. | ||
518 | |||
519 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
520 | |||
521 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
522 | |||
523 | const char *number The contents of the 'number' attribute (or NULL if not defined). | ||
524 | |||
525 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
526 | ++++++++++++++++++++++++++++++++++++++*/ | ||
527 | |||
528 | static int OrdinalType_function(const char *_tag_,int _type_,const char *number,const char *string) | ||
529 | { | ||
530 | if(_type_&XMLPARSE_TAG_START && store) | ||
531 | { | ||
532 | char *xmlstring; | ||
533 | int n; | ||
534 | |||
535 | XMLPARSE_ASSERT_INTEGER(_tag_,number); n=atoi(number); | ||
536 | XMLPARSE_ASSERT_STRING(_tag_,string); | ||
537 | |||
538 | if(n<1 || n>10) | ||
539 | XMLPARSE_INVALID(_tag_,number); | ||
540 | |||
541 | xmlstring=ParseXML_Encode_Safe_XML(string); | ||
542 | |||
543 | translate_xml_ordinal[n-1]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
544 | } | ||
545 | |||
546 | return(0); | ||
547 | } | ||
548 | |||
549 | |||
550 | /*++++++++++++++++++++++++++++++++++++++ | ||
551 | amb | 411 | The function that is called when the HighwayType XSD type is seen |
552 | |||
553 | int HighwayType_function Returns 0 if no error occured or something else otherwise. | ||
554 | |||
555 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
556 | |||
557 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
558 | |||
559 | const char *type The contents of the 'type' attribute (or NULL if not defined). | ||
560 | |||
561 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
562 | ++++++++++++++++++++++++++++++++++++++*/ | ||
563 | |||
564 | static int HighwayType_function(const char *_tag_,int _type_,const char *type,const char *string) | ||
565 | { | ||
566 | if(_type_&XMLPARSE_TAG_START && store) | ||
567 | { | ||
568 | Highway highway; | ||
569 | |||
570 | XMLPARSE_ASSERT_STRING(_tag_,type); | ||
571 | XMLPARSE_ASSERT_STRING(_tag_,string); | ||
572 | |||
573 | highway=HighwayType(type); | ||
574 | |||
575 | amb | 1174 | if(highway==Highway_None) |
576 | amb | 411 | XMLPARSE_INVALID(_tag_,type); |
577 | |||
578 | amb | 893 | translate_raw_highway[highway]=strcpy(malloc(strlen(string)+1),string); |
579 | amb | 411 | } |
580 | |||
581 | return(0); | ||
582 | } | ||
583 | |||
584 | |||
585 | /*++++++++++++++++++++++++++++++++++++++ | ||
586 | amb | 378 | The function that is called when the RouteType XSD type is seen |
587 | amb | 363 | |
588 | amb | 378 | int RouteType_function Returns 0 if no error occured or something else otherwise. |
589 | amb | 363 | |
590 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
591 | |||
592 | amb | 363 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. |
593 | |||
594 | amb | 361 | const char *type The contents of the 'type' attribute (or NULL if not defined). |
595 | |||
596 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
597 | ++++++++++++++++++++++++++++++++++++++*/ | ||
598 | |||
599 | amb | 378 | static int RouteType_function(const char *_tag_,int _type_,const char *type,const char *string) |
600 | amb | 361 | { |
601 | if(_type_&XMLPARSE_TAG_START && store) | ||
602 | { | ||
603 | amb | 486 | char *xmlstring; |
604 | |||
605 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,type); |
606 | XMLPARSE_ASSERT_STRING(_tag_,string); | ||
607 | amb | 361 | |
608 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
609 | |||
610 | amb | 361 | if(!strcmp(type,"shortest")) |
611 | amb | 893 | translate_xml_route_shortest=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
612 | amb | 361 | else if(!strcmp(type,"quickest")) |
613 | amb | 893 | translate_xml_route_quickest=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
614 | amb | 361 | else |
615 | amb | 373 | XMLPARSE_INVALID(_tag_,type); |
616 | amb | 361 | } |
617 | amb | 363 | |
618 | return(0); | ||
619 | amb | 361 | } |
620 | |||
621 | |||
622 | /*++++++++++++++++++++++++++++++++++++++ | ||
623 | amb | 1204 | The function that is called when the HTMLType XSD type is seen |
624 | amb | 375 | |
625 | amb | 1204 | int HTMLType_function Returns 0 if no error occured or something else otherwise. |
626 | amb | 375 | |
627 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
628 | |||
629 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
630 | amb | 1204 | ++++++++++++++++++++++++++++++++++++++*/ |
631 | amb | 378 | |
632 | amb | 1204 | //static int HTMLType_function(const char *_tag_,int _type_) |
633 | //{ | ||
634 | // return(0); | ||
635 | //} | ||
636 | amb | 378 | |
637 | amb | 1204 | |
638 | /*++++++++++++++++++++++++++++++++++++++ | ||
639 | The function that is called when the GPXType XSD type is seen | ||
640 | |||
641 | int GPXType_function Returns 0 if no error occured or something else otherwise. | ||
642 | |||
643 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
644 | |||
645 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
646 | ++++++++++++++++++++++++++++++++++++++*/ | ||
647 | |||
648 | //static int GPXType_function(const char *_tag_,int _type_) | ||
649 | //{ | ||
650 | // return(0); | ||
651 | //} | ||
652 | |||
653 | |||
654 | /*++++++++++++++++++++++++++++++++++++++ | ||
655 | The function that is called when the CopyrightCreatorType XSD type is seen | ||
656 | |||
657 | int CopyrightCreatorType_function Returns 0 if no error occured or something else otherwise. | ||
658 | |||
659 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
660 | |||
661 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
662 | |||
663 | amb | 378 | const char *string The contents of the 'string' attribute (or NULL if not defined). |
664 | amb | 1204 | |
665 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
666 | amb | 375 | ++++++++++++++++++++++++++++++++++++++*/ |
667 | |||
668 | amb | 1204 | static int CopyrightCreatorType_function(const char *_tag_,int _type_,const char *string,const char *text) |
669 | amb | 378 | { |
670 | if(_type_&XMLPARSE_TAG_START && store) | ||
671 | { | ||
672 | amb | 1204 | char *xmlstring,*xmltext; |
673 | amb | 486 | |
674 | amb | 378 | XMLPARSE_ASSERT_STRING(_tag_,string); |
675 | amb | 1204 | XMLPARSE_ASSERT_STRING(_tag_,text); |
676 | amb | 375 | |
677 | amb | 1204 | translate_raw_copyright_creator[0]=strcpy(malloc(strlen(string)+1),string); |
678 | translate_raw_copyright_creator[1]=strcpy(malloc(strlen(text)+1) ,text); | ||
679 | |||
680 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
681 | amb | 1204 | xmltext =ParseXML_Encode_Safe_XML(text); |
682 | amb | 486 | |
683 | amb | 1204 | translate_xml_copyright_creator[0]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
684 | translate_xml_copyright_creator[1]=strcpy(malloc(strlen(xmltext)+1) ,xmltext); | ||
685 | amb | 378 | } |
686 | amb | 375 | |
687 | amb | 378 | return(0); |
688 | } | ||
689 | |||
690 | |||
691 | amb | 375 | /*++++++++++++++++++++++++++++++++++++++ |
692 | amb | 1204 | The function that is called when the CopyrightSourceType XSD type is seen |
693 | amb | 361 | |
694 | amb | 1204 | int CopyrightSourceType_function Returns 0 if no error occured or something else otherwise. |
695 | amb | 363 | |
696 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
697 | |||
698 | amb | 361 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. |
699 | |||
700 | amb | 1204 | const char *string The contents of the 'string' attribute (or NULL if not defined). |
701 | amb | 361 | |
702 | amb | 1204 | const char *text The contents of the 'text' attribute (or NULL if not defined). |
703 | ++++++++++++++++++++++++++++++++++++++*/ | ||
704 | |||
705 | static int CopyrightSourceType_function(const char *_tag_,int _type_,const char *string,const char *text) | ||
706 | { | ||
707 | if(_type_&XMLPARSE_TAG_START && store) | ||
708 | { | ||
709 | char *xmlstring,*xmltext; | ||
710 | |||
711 | XMLPARSE_ASSERT_STRING(_tag_,string); | ||
712 | XMLPARSE_ASSERT_STRING(_tag_,text); | ||
713 | |||
714 | translate_raw_copyright_source[0]=strcpy(malloc(strlen(string)+1),string); | ||
715 | translate_raw_copyright_source[1]=strcpy(malloc(strlen(text)+1) ,text); | ||
716 | |||
717 | xmlstring=ParseXML_Encode_Safe_XML(string); | ||
718 | xmltext =ParseXML_Encode_Safe_XML(text); | ||
719 | |||
720 | translate_xml_copyright_source[0]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
721 | translate_xml_copyright_source[1]=strcpy(malloc(strlen(xmltext)+1) ,xmltext); | ||
722 | } | ||
723 | |||
724 | return(0); | ||
725 | } | ||
726 | |||
727 | |||
728 | /*++++++++++++++++++++++++++++++++++++++ | ||
729 | The function that is called when the CopyrightLicenseType XSD type is seen | ||
730 | |||
731 | int CopyrightLicenseType_function Returns 0 if no error occured or something else otherwise. | ||
732 | |||
733 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
734 | |||
735 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
736 | |||
737 | amb | 361 | const char *string The contents of the 'string' attribute (or NULL if not defined). |
738 | amb | 1204 | |
739 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
740 | amb | 361 | ++++++++++++++++++++++++++++++++++++++*/ |
741 | |||
742 | amb | 1204 | static int CopyrightLicenseType_function(const char *_tag_,int _type_,const char *string,const char *text) |
743 | amb | 361 | { |
744 | if(_type_&XMLPARSE_TAG_START && store) | ||
745 | { | ||
746 | amb | 1204 | char *xmlstring,*xmltext; |
747 | amb | 486 | |
748 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,string); |
749 | amb | 1204 | XMLPARSE_ASSERT_STRING(_tag_,text); |
750 | amb | 361 | |
751 | amb | 1204 | translate_raw_copyright_license[0]=strcpy(malloc(strlen(string)+1),string); |
752 | translate_raw_copyright_license[1]=strcpy(malloc(strlen(text)+1) ,text); | ||
753 | |||
754 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
755 | amb | 1204 | xmltext =ParseXML_Encode_Safe_XML(text); |
756 | amb | 486 | |
757 | amb | 1204 | translate_xml_copyright_license[0]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
758 | translate_xml_copyright_license[1]=strcpy(malloc(strlen(xmltext)+1) ,xmltext); | ||
759 | amb | 361 | } |
760 | amb | 363 | |
761 | return(0); | ||
762 | amb | 361 | } |
763 | |||
764 | |||
765 | /*++++++++++++++++++++++++++++++++++++++ | ||
766 | amb | 1204 | The function that is called when the HTMLWaypointType XSD type is seen |
767 | amb | 378 | |
768 | amb | 1204 | int HTMLWaypointType_function Returns 0 if no error occured or something else otherwise. |
769 | amb | 378 | |
770 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
771 | |||
772 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
773 | amb | 1204 | |
774 | const char *type The contents of the 'type' attribute (or NULL if not defined). | ||
775 | |||
776 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
777 | amb | 378 | ++++++++++++++++++++++++++++++++++++++*/ |
778 | |||
779 | amb | 1204 | static int HTMLWaypointType_function(const char *_tag_,int _type_,const char *type,const char *string) |
780 | { | ||
781 | if(_type_&XMLPARSE_TAG_START && store) | ||
782 | { | ||
783 | char *xmlstring; | ||
784 | amb | 378 | |
785 | amb | 1204 | XMLPARSE_ASSERT_STRING(_tag_,type); |
786 | XMLPARSE_ASSERT_STRING(_tag_,string); | ||
787 | amb | 378 | |
788 | amb | 1204 | xmlstring=ParseXML_Encode_Safe_XML(string); |
789 | |||
790 | if(!strcmp(type,"waypoint")) | ||
791 | { | ||
792 | translate_html_waypoint=malloc(strlen(xmlstring)+1+sizeof("<span class='w'>")+sizeof("</span>")); | ||
793 | sprintf(translate_html_waypoint,"<span class='w'>%s</span>",xmlstring); | ||
794 | } | ||
795 | else if(!strcmp(type,"junction")) | ||
796 | translate_html_junction=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
797 | else if(!strcmp(type,"roundabout")) | ||
798 | translate_html_roundabout=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
799 | else | ||
800 | XMLPARSE_INVALID(_tag_,type); | ||
801 | } | ||
802 | |||
803 | return(0); | ||
804 | } | ||
805 | |||
806 | |||
807 | amb | 378 | /*++++++++++++++++++++++++++++++++++++++ |
808 | The function that is called when the HTMLTitleType XSD type is seen | ||
809 | |||
810 | int HTMLTitleType_function Returns 0 if no error occured or something else otherwise. | ||
811 | |||
812 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
813 | |||
814 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
815 | |||
816 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
817 | ++++++++++++++++++++++++++++++++++++++*/ | ||
818 | |||
819 | static int HTMLTitleType_function(const char *_tag_,int _type_,const char *text) | ||
820 | { | ||
821 | if(_type_&XMLPARSE_TAG_START && store) | ||
822 | { | ||
823 | amb | 486 | char *xmltext; |
824 | |||
825 | amb | 378 | XMLPARSE_ASSERT_STRING(_tag_,text); |
826 | |||
827 | amb | 486 | xmltext=ParseXML_Encode_Safe_XML(text); |
828 | |||
829 | translate_html_title=strcpy(malloc(strlen(xmltext)+1),xmltext); | ||
830 | amb | 378 | } |
831 | |||
832 | return(0); | ||
833 | } | ||
834 | |||
835 | |||
836 | /*++++++++++++++++++++++++++++++++++++++ | ||
837 | The function that is called when the HTMLStartType XSD type is seen | ||
838 | |||
839 | int HTMLStartType_function Returns 0 if no error occured or something else otherwise. | ||
840 | |||
841 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
842 | |||
843 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
844 | |||
845 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
846 | |||
847 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
848 | ++++++++++++++++++++++++++++++++++++++*/ | ||
849 | |||
850 | static int HTMLStartType_function(const char *_tag_,int _type_,const char *string,const char *text) | ||
851 | { | ||
852 | if(_type_&XMLPARSE_TAG_START && store) | ||
853 | { | ||
854 | amb | 486 | char *xmlstring,*xmltext; |
855 | |||
856 | amb | 378 | XMLPARSE_ASSERT_STRING(_tag_,string); |
857 | XMLPARSE_ASSERT_STRING(_tag_,text); | ||
858 | |||
859 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
860 | xmltext =ParseXML_Encode_Safe_XML(text); | ||
861 | |||
862 | translate_html_start[0]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
863 | translate_html_start[1]=malloc(strlen(xmltext)+1+sizeof("<span class='b'>")+sizeof("</span>")); | ||
864 | sprintf(translate_html_start[1],xmltext,"%s","<span class='b'>%s</span>"); | ||
865 | amb | 378 | } |
866 | |||
867 | return(0); | ||
868 | } | ||
869 | |||
870 | |||
871 | /*++++++++++++++++++++++++++++++++++++++ | ||
872 | The function that is called when the HTMLNodeType XSD type is seen | ||
873 | |||
874 | int HTMLNodeType_function Returns 0 if no error occured or something else otherwise. | ||
875 | |||
876 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
877 | |||
878 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
879 | |||
880 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
881 | |||
882 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
883 | ++++++++++++++++++++++++++++++++++++++*/ | ||
884 | |||
885 | static int HTMLNodeType_function(const char *_tag_,int _type_,const char *string,const char *text) | ||
886 | { | ||
887 | if(_type_&XMLPARSE_TAG_START && store) | ||
888 | { | ||
889 | amb | 486 | char *xmlstring,*xmltext; |
890 | |||
891 | amb | 378 | XMLPARSE_ASSERT_STRING(_tag_,string); |
892 | XMLPARSE_ASSERT_STRING(_tag_,text); | ||
893 | |||
894 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
895 | xmltext =ParseXML_Encode_Safe_XML(text); | ||
896 | |||
897 | translate_html_node[0]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
898 | translate_html_node[1]=malloc(strlen(xmltext)+1+2*sizeof("<span class='b'>")+2*sizeof("</span>")); | ||
899 | sprintf(translate_html_node[1],xmltext,"%s","<span class='t'>%s</span>","<span class='b'>%s</span>"); | ||
900 | amb | 378 | } |
901 | |||
902 | return(0); | ||
903 | } | ||
904 | |||
905 | |||
906 | /*++++++++++++++++++++++++++++++++++++++ | ||
907 | amb | 925 | The function that is called when the HTMLRBNodeType XSD type is seen |
908 | |||
909 | int HTMLRBNodeType_function Returns 0 if no error occured or something else otherwise. | ||
910 | |||
911 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
912 | |||
913 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
914 | |||
915 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
916 | |||
917 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
918 | ++++++++++++++++++++++++++++++++++++++*/ | ||
919 | |||
920 | static int HTMLRBNodeType_function(const char *_tag_,int _type_,const char *string,const char *text) | ||
921 | { | ||
922 | if(_type_&XMLPARSE_TAG_START && store) | ||
923 | { | ||
924 | char *xmlstring,*xmltext; | ||
925 | |||
926 | XMLPARSE_ASSERT_STRING(_tag_,string); | ||
927 | XMLPARSE_ASSERT_STRING(_tag_,text); | ||
928 | |||
929 | xmlstring=ParseXML_Encode_Safe_XML(string); | ||
930 | xmltext =ParseXML_Encode_Safe_XML(text); | ||
931 | |||
932 | translate_html_rbnode[0]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
933 | translate_html_rbnode[1]=malloc(strlen(xmltext)+1+2*sizeof("<span class='b'>")+2*sizeof("</span>")); | ||
934 | sprintf(translate_html_rbnode[1],xmltext,"%s","<span class='t'>%s</span>","<span class='b'>%s</span>"); | ||
935 | } | ||
936 | |||
937 | return(0); | ||
938 | } | ||
939 | |||
940 | |||
941 | /*++++++++++++++++++++++++++++++++++++++ | ||
942 | amb | 378 | The function that is called when the HTMLSegmentType XSD type is seen |
943 | |||
944 | int HTMLSegmentType_function Returns 0 if no error occured or something else otherwise. | ||
945 | |||
946 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
947 | |||
948 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
949 | |||
950 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
951 | |||
952 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
953 | ++++++++++++++++++++++++++++++++++++++*/ | ||
954 | |||
955 | static int HTMLSegmentType_function(const char *_tag_,int _type_,const char *string,const char *text) | ||
956 | { | ||
957 | if(_type_&XMLPARSE_TAG_START && store) | ||
958 | { | ||
959 | amb | 486 | char *xmlstring,*xmltext; |
960 | amb | 378 | const char *p; |
961 | char *q; | ||
962 | |||
963 | XMLPARSE_ASSERT_STRING(_tag_,string); | ||
964 | XMLPARSE_ASSERT_STRING(_tag_,text); | ||
965 | |||
966 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
967 | xmltext =ParseXML_Encode_Safe_XML(text); | ||
968 | amb | 378 | |
969 | amb | 486 | translate_html_segment[0]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
970 | translate_html_segment[1]=malloc(strlen(xmltext)+1+2*sizeof("<span class='b'>")+2*sizeof("</span>")); | ||
971 | |||
972 | p=xmltext; | ||
973 | amb | 378 | q=translate_html_segment[1]; |
974 | |||
975 | while(*p!='%' && *(p+1)!='s') | ||
976 | *q++=*p++; | ||
977 | |||
978 | p+=2; | ||
979 | strcpy(q,"<span class='h'>%s</span>"); q+=sizeof("<span class='h'>%s</span>")-1; | ||
980 | |||
981 | while(*p!='%') | ||
982 | *q++=*p++; | ||
983 | |||
984 | strcpy(q,"<span class='d'>"); q+=sizeof("<span class='d'>")-1; | ||
985 | |||
986 | strcpy(q,p); | ||
987 | strcat(q,"</span>"); | ||
988 | } | ||
989 | |||
990 | return(0); | ||
991 | } | ||
992 | |||
993 | |||
994 | /*++++++++++++++++++++++++++++++++++++++ | ||
995 | The function that is called when the HTMLStopType XSD type is seen | ||
996 | |||
997 | int HTMLStopType_function Returns 0 if no error occured or something else otherwise. | ||
998 | |||
999 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
1000 | |||
1001 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
1002 | |||
1003 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
1004 | |||
1005 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1006 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1007 | |||
1008 | static int HTMLStopType_function(const char *_tag_,int _type_,const char *string,const char *text) | ||
1009 | { | ||
1010 | if(_type_&XMLPARSE_TAG_START && store) | ||
1011 | { | ||
1012 | amb | 486 | char *xmlstring,*xmltext; |
1013 | |||
1014 | amb | 378 | XMLPARSE_ASSERT_STRING(_tag_,string); |
1015 | XMLPARSE_ASSERT_STRING(_tag_,text); | ||
1016 | |||
1017 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
1018 | xmltext =ParseXML_Encode_Safe_XML(text); | ||
1019 | |||
1020 | translate_html_stop[0]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
1021 | translate_html_stop[1]=strcpy(malloc(strlen(xmltext)+1) ,xmltext); | ||
1022 | amb | 378 | } |
1023 | |||
1024 | return(0); | ||
1025 | } | ||
1026 | |||
1027 | |||
1028 | /*++++++++++++++++++++++++++++++++++++++ | ||
1029 | The function that is called when the HTMLTotalType XSD type is seen | ||
1030 | |||
1031 | int HTMLTotalType_function Returns 0 if no error occured or something else otherwise. | ||
1032 | |||
1033 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
1034 | |||
1035 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
1036 | |||
1037 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
1038 | |||
1039 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1040 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1041 | |||
1042 | static int HTMLTotalType_function(const char *_tag_,int _type_,const char *string,const char *text) | ||
1043 | { | ||
1044 | if(_type_&XMLPARSE_TAG_START && store) | ||
1045 | { | ||
1046 | amb | 486 | char *xmlstring,*xmltext; |
1047 | |||
1048 | amb | 378 | XMLPARSE_ASSERT_STRING(_tag_,string); |
1049 | XMLPARSE_ASSERT_STRING(_tag_,text); | ||
1050 | |||
1051 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
1052 | xmltext =ParseXML_Encode_Safe_XML(text); | ||
1053 | |||
1054 | translate_html_total[0]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
1055 | translate_html_total[1]=strcpy(malloc(strlen(xmltext)+1) ,xmltext); | ||
1056 | amb | 378 | } |
1057 | |||
1058 | return(0); | ||
1059 | } | ||
1060 | |||
1061 | |||
1062 | /*++++++++++++++++++++++++++++++++++++++ | ||
1063 | amb | 1204 | The function that is called when the GPXWaypointType XSD type is seen |
1064 | amb | 378 | |
1065 | amb | 1204 | int GPXWaypointType_function Returns 0 if no error occured or something else otherwise. |
1066 | amb | 378 | |
1067 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
1068 | |||
1069 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
1070 | amb | 1204 | |
1071 | const char *type The contents of the 'type' attribute (or NULL if not defined). | ||
1072 | |||
1073 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
1074 | amb | 378 | ++++++++++++++++++++++++++++++++++++++*/ |
1075 | |||
1076 | amb | 1204 | static int GPXWaypointType_function(const char *_tag_,int _type_,const char *type,const char *string) |
1077 | { | ||
1078 | if(_type_&XMLPARSE_TAG_START && store) | ||
1079 | { | ||
1080 | char *xmlstring; | ||
1081 | amb | 378 | |
1082 | amb | 1204 | XMLPARSE_ASSERT_STRING(_tag_,type); |
1083 | XMLPARSE_ASSERT_STRING(_tag_,string); | ||
1084 | amb | 378 | |
1085 | amb | 1204 | xmlstring=ParseXML_Encode_Safe_XML(string); |
1086 | |||
1087 | if(!strcmp(type,"start")) | ||
1088 | translate_gpx_start=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
1089 | else if(!strcmp(type,"inter")) | ||
1090 | translate_gpx_inter=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
1091 | else if(!strcmp(type,"trip")) | ||
1092 | translate_gpx_trip=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
1093 | else if(!strcmp(type,"finish")) | ||
1094 | translate_gpx_finish=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
1095 | else | ||
1096 | XMLPARSE_INVALID(_tag_,type); | ||
1097 | } | ||
1098 | |||
1099 | return(0); | ||
1100 | } | ||
1101 | |||
1102 | |||
1103 | amb | 378 | /*++++++++++++++++++++++++++++++++++++++ |
1104 | amb | 361 | The function that is called when the GPXDescType XSD type is seen |
1105 | |||
1106 | amb | 367 | int GPXDescType_function Returns 0 if no error occured or something else otherwise. |
1107 | amb | 363 | |
1108 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
1109 | |||
1110 | amb | 361 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. |
1111 | |||
1112 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1113 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1114 | |||
1115 | amb | 373 | static int GPXDescType_function(const char *_tag_,int _type_,const char *text) |
1116 | amb | 361 | { |
1117 | if(_type_&XMLPARSE_TAG_START && store) | ||
1118 | { | ||
1119 | amb | 486 | char *xmltext; |
1120 | |||
1121 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1122 | amb | 361 | |
1123 | amb | 486 | xmltext=ParseXML_Encode_Safe_XML(text); |
1124 | |||
1125 | translate_gpx_desc=strcpy(malloc(strlen(xmltext)+1),xmltext); | ||
1126 | amb | 361 | } |
1127 | amb | 363 | |
1128 | return(0); | ||
1129 | amb | 361 | } |
1130 | |||
1131 | |||
1132 | /*++++++++++++++++++++++++++++++++++++++ | ||
1133 | The function that is called when the GPXNameType XSD type is seen | ||
1134 | |||
1135 | amb | 367 | int GPXNameType_function Returns 0 if no error occured or something else otherwise. |
1136 | amb | 363 | |
1137 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
1138 | |||
1139 | amb | 361 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. |
1140 | |||
1141 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1142 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1143 | |||
1144 | amb | 373 | static int GPXNameType_function(const char *_tag_,int _type_,const char *text) |
1145 | amb | 361 | { |
1146 | if(_type_&XMLPARSE_TAG_START && store) | ||
1147 | { | ||
1148 | amb | 486 | char *xmltext; |
1149 | |||
1150 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1151 | amb | 361 | |
1152 | amb | 486 | xmltext=ParseXML_Encode_Safe_XML(text); |
1153 | |||
1154 | translate_gpx_name=strcpy(malloc(strlen(xmltext)+1),xmltext); | ||
1155 | amb | 361 | } |
1156 | amb | 363 | |
1157 | return(0); | ||
1158 | amb | 361 | } |
1159 | |||
1160 | |||
1161 | /*++++++++++++++++++++++++++++++++++++++ | ||
1162 | The function that is called when the GPXStepType XSD type is seen | ||
1163 | |||
1164 | amb | 367 | int GPXStepType_function Returns 0 if no error occured or something else otherwise. |
1165 | amb | 363 | |
1166 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
1167 | |||
1168 | amb | 361 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. |
1169 | |||
1170 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1171 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1172 | |||
1173 | amb | 373 | static int GPXStepType_function(const char *_tag_,int _type_,const char *text) |
1174 | amb | 361 | { |
1175 | if(_type_&XMLPARSE_TAG_START && store) | ||
1176 | { | ||
1177 | amb | 486 | char *xmltext; |
1178 | |||
1179 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1180 | amb | 361 | |
1181 | amb | 486 | xmltext=ParseXML_Encode_Safe_XML(text); |
1182 | |||
1183 | translate_gpx_step=strcpy(malloc(strlen(xmltext)+1),xmltext); | ||
1184 | amb | 361 | } |
1185 | amb | 363 | |
1186 | return(0); | ||
1187 | amb | 361 | } |
1188 | |||
1189 | |||
1190 | /*++++++++++++++++++++++++++++++++++++++ | ||
1191 | The function that is called when the GPXFinalType XSD type is seen | ||
1192 | |||
1193 | amb | 367 | int GPXFinalType_function Returns 0 if no error occured or something else otherwise. |
1194 | amb | 363 | |
1195 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
1196 | |||
1197 | amb | 361 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. |
1198 | |||
1199 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1200 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1201 | |||
1202 | amb | 373 | static int GPXFinalType_function(const char *_tag_,int _type_,const char *text) |
1203 | amb | 361 | { |
1204 | if(_type_&XMLPARSE_TAG_START && store) | ||
1205 | { | ||
1206 | amb | 486 | char *xmltext; |
1207 | |||
1208 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1209 | amb | 361 | |
1210 | amb | 486 | xmltext=ParseXML_Encode_Safe_XML(text); |
1211 | |||
1212 | translate_gpx_final=strcpy(malloc(strlen(xmltext)+1),xmltext); | ||
1213 | amb | 361 | } |
1214 | amb | 363 | |
1215 | return(0); | ||
1216 | amb | 361 | } |
1217 | |||
1218 | |||
1219 | /*++++++++++++++++++++++++++++++++++++++ | ||
1220 | The XML translation parser. | ||
1221 | |||
1222 | int ParseXMLTranslations Returns 0 if OK or something else in case of an error. | ||
1223 | |||
1224 | const char *filename The name of the file to read. | ||
1225 | |||
1226 | const char *language The language to search for (NULL means first in file). | ||
1227 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1228 | |||
1229 | int ParseXMLTranslations(const char *filename,const char *language) | ||
1230 | { | ||
1231 | amb | 1186 | int fd; |
1232 | amb | 361 | int retval; |
1233 | |||
1234 | store_lang=language; | ||
1235 | |||
1236 | if(!ExistsFile(filename)) | ||
1237 | { | ||
1238 | fprintf(stderr,"Error: Specified translations file '%s' does not exist.\n",filename); | ||
1239 | return(1); | ||
1240 | } | ||
1241 | |||
1242 | amb | 1410 | fd=ReOpenFileUnbuffered(filename); |
1243 | amb | 361 | |
1244 | amb | 1186 | retval=ParseXML(fd,xml_toplevel_tags,XMLPARSE_UNKNOWN_ATTR_ERRNONAME|XMLPARSE_RETURN_ATTR_ENCODED); |
1245 | amb | 361 | |
1246 | amb | 1410 | CloseFileUnbuffered(fd); |
1247 | amb | 361 | |
1248 | amb | 363 | if(retval) |
1249 | amb | 361 | return(1); |
1250 | |||
1251 | if(language && !stored) | ||
1252 | fprintf(stderr,"Warning: Cannot find translations for language '%s' using English instead.\n",language); | ||
1253 | |||
1254 | return(0); | ||
1255 | } |
Properties
Name | Value |
---|---|
cvs:description | File containing translation parsing functions. |