Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Contents of /trunk/src/translations.c
Parent Directory
|
Revision Log
Revision 1205 -
(show annotations)
(download)
(as text)
Sat Dec 15 15:57:46 2012 UTC (12 years, 3 months ago) by amb
File MIME type: text/x-csrc
File size: 41865 byte(s)
Sat Dec 15 15:57:46 2012 UTC (12 years, 3 months ago) by amb
File MIME type: text/x-csrc
File size: 41865 byte(s)
Change one entry in the translations XSD file that used a different case from the other defined types (not consistent with other XSD files but self-consistent).
1 | /*************************************** |
2 | Load the translations from a file and the functions for handling them. |
3 | |
4 | Part of the Routino routing software. |
5 | ******************/ /****************** |
6 | This file Copyright 2010-2012 Andrew M. Bishop |
7 | |
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 | #include "files.h" |
28 | #include "translations.h" |
29 | #include "xmlparse.h" |
30 | |
31 | |
32 | /* Global variables - default English values - Must not require any UTF-8 encoding */ |
33 | |
34 | 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 | |
38 | 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 | |
42 | 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 | |
46 | 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 | |
48 | char *translate_xml_route_shortest="Shortest"; |
49 | char *translate_xml_route_quickest="Quickest"; |
50 | |
51 | char *translate_html_waypoint ="<span class='w'>Waypoint</span>"; |
52 | char *translate_html_junction ="Junction"; |
53 | char *translate_html_roundabout="Roundabout"; |
54 | |
55 | char *translate_html_title ="%s Route"; |
56 | char *translate_html_start[2] ={"Start","At %s, head %s"}; |
57 | char *translate_html_segment[2]={"Follow","%s for %.3f km, %.1f min"}; |
58 | char *translate_html_node[2] ={"At","%s, go %s heading %s"}; |
59 | char *translate_html_rbnode[2] ={"Leave","%s, take the %s exit heading %s"}; |
60 | char *translate_html_stop[2] ={"Stop","At %s"}; |
61 | char *translate_html_total[2] ={"Total","%.1f km, %.0f minutes"}; |
62 | |
63 | char *translate_gpx_desc ="%s between 'start' and 'finish' waypoints"; |
64 | char *translate_gpx_name ="%s Route"; |
65 | char *translate_gpx_step ="%s on '%s' for %.3f km, %.1 min"; |
66 | char *translate_gpx_final="Total Journey %.1f km, %d minutes"; |
67 | |
68 | char *translate_gpx_start ="START"; |
69 | char *translate_gpx_inter ="INTER"; |
70 | char *translate_gpx_trip ="TRIP"; |
71 | 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 | //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 | static int LanguageType_function(const char *_tag_,int _type_,const char *lang); |
91 | //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 | //static int GPXType_function(const char *_tag_,int _type_); |
99 | 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 | static int HTMLTotalType_function(const char *_tag_,int _type_,const char *string,const char *text); |
110 | static int GPXWaypointType_function(const char *_tag_,int _type_,const char *type,const char *string); |
111 | 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 | |
116 | |
117 | /* The XML tag definitions (forward declarations) */ |
118 | |
119 | static xmltag xmlDeclaration_tag; |
120 | static xmltag RoutinoTranslationsType_tag; |
121 | static xmltag LanguageType_tag; |
122 | 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 | |
147 | |
148 | /* 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 | {NULL}}; |
159 | |
160 | /*+ The RoutinoTranslationsType type tag. +*/ |
161 | static xmltag RoutinoTranslationsType_tag= |
162 | {"routino-translations", |
163 | 0, {NULL}, |
164 | NULL, |
165 | {&LanguageType_tag,NULL}}; |
166 | |
167 | /*+ The LanguageType type tag. +*/ |
168 | static xmltag LanguageType_tag= |
169 | {"language", |
170 | 1, {"lang"}, |
171 | LanguageType_function, |
172 | {&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 | /*+ The TurnType type tag. +*/ |
182 | static xmltag TurnType_tag= |
183 | {"turn", |
184 | 2, {"direction","string"}, |
185 | TurnType_function, |
186 | {NULL}}; |
187 | |
188 | /*+ The HeadingType type tag. +*/ |
189 | static xmltag HeadingType_tag= |
190 | {"heading", |
191 | 2, {"direction","string"}, |
192 | HeadingType_function, |
193 | {NULL}}; |
194 | |
195 | /*+ The OrdinalType type tag. +*/ |
196 | static xmltag OrdinalType_tag= |
197 | {"ordinal", |
198 | 2, {"number","string"}, |
199 | OrdinalType_function, |
200 | {NULL}}; |
201 | |
202 | /*+ The HighwayType type tag. +*/ |
203 | static xmltag HighwayType_tag= |
204 | {"highway", |
205 | 2, {"type","string"}, |
206 | HighwayType_function, |
207 | {NULL}}; |
208 | |
209 | /*+ The RouteType type tag. +*/ |
210 | static xmltag RouteType_tag= |
211 | {"route", |
212 | 2, {"type","string"}, |
213 | RouteType_function, |
214 | {NULL}}; |
215 | |
216 | /*+ 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 | /*+ The HTMLWaypointType type tag. +*/ |
252 | static xmltag HTMLWaypointType_tag= |
253 | {"waypoint", |
254 | 2, {"type","string"}, |
255 | HTMLWaypointType_function, |
256 | {NULL}}; |
257 | |
258 | /*+ The HTMLTitleType type tag. +*/ |
259 | static xmltag HTMLTitleType_tag= |
260 | {"title", |
261 | 1, {"text"}, |
262 | HTMLTitleType_function, |
263 | {NULL}}; |
264 | |
265 | /*+ 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 | /*+ The HTMLRBNodeType type tag. +*/ |
280 | static xmltag HTMLRBNodeType_tag= |
281 | {"rbnode", |
282 | 2, {"string","text"}, |
283 | HTMLRBNodeType_function, |
284 | {NULL}}; |
285 | |
286 | /*+ 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 | /*+ The GPXWaypointType type tag. +*/ |
308 | static xmltag GPXWaypointType_tag= |
309 | {"waypoint", |
310 | 2, {"type","string"}, |
311 | GPXWaypointType_function, |
312 | {NULL}}; |
313 | |
314 | /*+ The GPXDescType type tag. +*/ |
315 | static xmltag GPXDescType_tag= |
316 | {"desc", |
317 | 1, {"text"}, |
318 | GPXDescType_function, |
319 | {NULL}}; |
320 | |
321 | /*+ The GPXNameType type tag. +*/ |
322 | static xmltag GPXNameType_tag= |
323 | {"name", |
324 | 1, {"text"}, |
325 | GPXNameType_function, |
326 | {NULL}}; |
327 | |
328 | /*+ The GPXStepType type tag. +*/ |
329 | static xmltag GPXStepType_tag= |
330 | {"step", |
331 | 1, {"text"}, |
332 | GPXStepType_function, |
333 | {NULL}}; |
334 | |
335 | /*+ The GPXFinalType type tag. +*/ |
336 | static xmltag GPXFinalType_tag= |
337 | {"final", |
338 | 1, {"text"}, |
339 | GPXFinalType_function, |
340 | {NULL}}; |
341 | |
342 | |
343 | /* The XML tag processing functions */ |
344 | |
345 | |
346 | /*++++++++++++++++++++++++++++++++++++++ |
347 | The function that is called when the XML declaration is seen |
348 | |
349 | int xmlDeclaration_function Returns 0 if no error occured or something else otherwise. |
350 | |
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 | const char *version The contents of the 'version' attribute (or NULL if not defined). |
356 | |
357 | const char *encoding The contents of the 'encoding' attribute (or NULL if not defined). |
358 | ++++++++++++++++++++++++++++++++++++++*/ |
359 | |
360 | //static int xmlDeclaration_function(const char *_tag_,int _type_,const char *version,const char *encoding) |
361 | //{ |
362 | // return(0); |
363 | //} |
364 | |
365 | |
366 | /*++++++++++++++++++++++++++++++++++++++ |
367 | The function that is called when the RoutinoTranslationsType XSD type is seen |
368 | |
369 | int RoutinoTranslationsType_function Returns 0 if no error occured or something else otherwise. |
370 | |
371 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
372 | |
373 | 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 | |
376 | //static int RoutinoTranslationsType_function(const char *_tag_,int _type_) |
377 | //{ |
378 | // return(0); |
379 | //} |
380 | |
381 | |
382 | /*++++++++++++++++++++++++++++++++++++++ |
383 | The function that is called when the LanguageType XSD type is seen |
384 | |
385 | int LanguageType_function Returns 0 if no error occured or something else otherwise. |
386 | |
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 | const char *lang The contents of the 'lang' attribute (or NULL if not defined). |
392 | ++++++++++++++++++++++++++++++++++++++*/ |
393 | |
394 | static int LanguageType_function(const char *_tag_,int _type_,const char *lang) |
395 | { |
396 | static int first=1; |
397 | |
398 | if(_type_&XMLPARSE_TAG_START) |
399 | { |
400 | XMLPARSE_ASSERT_STRING(_tag_,lang); |
401 | |
402 | 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 | |
409 | first=0; |
410 | } |
411 | |
412 | if(_type_&XMLPARSE_TAG_END && store) |
413 | { |
414 | store=0; |
415 | stored=1; |
416 | } |
417 | |
418 | return(0); |
419 | } |
420 | |
421 | |
422 | /*++++++++++++++++++++++++++++++++++++++ |
423 | The function that is called when the CopyrightType XSD type is seen |
424 | |
425 | int CopyrightType_function Returns 0 if no error occured or something else otherwise. |
426 | |
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 | //static int CopyrightType_function(const char *_tag_,int _type_) |
433 | //{ |
434 | // return(0); |
435 | //} |
436 | |
437 | |
438 | /*++++++++++++++++++++++++++++++++++++++ |
439 | The function that is called when the TurnType XSD type is seen |
440 | |
441 | int TurnType_function Returns 0 if no error occured or something else otherwise. |
442 | |
443 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
444 | |
445 | 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 | static int TurnType_function(const char *_tag_,int _type_,const char *direction,const char *string) |
453 | { |
454 | if(_type_&XMLPARSE_TAG_START && store) |
455 | { |
456 | char *xmlstring; |
457 | int d; |
458 | |
459 | XMLPARSE_ASSERT_INTEGER(_tag_,direction); d=atoi(direction); |
460 | XMLPARSE_ASSERT_STRING(_tag_,string); |
461 | |
462 | d+=4; |
463 | |
464 | if(d<0 || d>8) |
465 | XMLPARSE_INVALID(_tag_,direction); |
466 | |
467 | xmlstring=ParseXML_Encode_Safe_XML(string); |
468 | |
469 | translate_xml_turn[d]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
470 | } |
471 | |
472 | return(0); |
473 | } |
474 | |
475 | |
476 | /*++++++++++++++++++++++++++++++++++++++ |
477 | The function that is called when the HeadingType XSD type is seen |
478 | |
479 | int HeadingType_function Returns 0 if no error occured or something else otherwise. |
480 | |
481 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
482 | |
483 | 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 | static int HeadingType_function(const char *_tag_,int _type_,const char *direction,const char *string) |
491 | { |
492 | if(_type_&XMLPARSE_TAG_START && store) |
493 | { |
494 | char *xmlstring; |
495 | int d; |
496 | |
497 | XMLPARSE_ASSERT_INTEGER(_tag_,direction); d=atoi(direction); |
498 | XMLPARSE_ASSERT_STRING(_tag_,string); |
499 | |
500 | d+=4; |
501 | |
502 | if(d<0 || d>8) |
503 | XMLPARSE_INVALID(_tag_,direction); |
504 | |
505 | xmlstring=ParseXML_Encode_Safe_XML(string); |
506 | |
507 | translate_xml_heading[d]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
508 | } |
509 | |
510 | return(0); |
511 | } |
512 | |
513 | |
514 | /*++++++++++++++++++++++++++++++++++++++ |
515 | 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 | 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 | if(highway==Highway_None) |
576 | XMLPARSE_INVALID(_tag_,type); |
577 | |
578 | translate_raw_highway[highway]=strcpy(malloc(strlen(string)+1),string); |
579 | } |
580 | |
581 | return(0); |
582 | } |
583 | |
584 | |
585 | /*++++++++++++++++++++++++++++++++++++++ |
586 | The function that is called when the RouteType XSD type is seen |
587 | |
588 | int RouteType_function Returns 0 if no error occured or something else otherwise. |
589 | |
590 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
591 | |
592 | 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 | 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 | static int RouteType_function(const char *_tag_,int _type_,const char *type,const char *string) |
600 | { |
601 | if(_type_&XMLPARSE_TAG_START && store) |
602 | { |
603 | char *xmlstring; |
604 | |
605 | XMLPARSE_ASSERT_STRING(_tag_,type); |
606 | XMLPARSE_ASSERT_STRING(_tag_,string); |
607 | |
608 | xmlstring=ParseXML_Encode_Safe_XML(string); |
609 | |
610 | if(!strcmp(type,"shortest")) |
611 | translate_xml_route_shortest=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
612 | else if(!strcmp(type,"quickest")) |
613 | translate_xml_route_quickest=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
614 | else |
615 | XMLPARSE_INVALID(_tag_,type); |
616 | } |
617 | |
618 | return(0); |
619 | } |
620 | |
621 | |
622 | /*++++++++++++++++++++++++++++++++++++++ |
623 | The function that is called when the HTMLType XSD type is seen |
624 | |
625 | int HTMLType_function Returns 0 if no error occured or something else otherwise. |
626 | |
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 | ++++++++++++++++++++++++++++++++++++++*/ |
631 | |
632 | //static int HTMLType_function(const char *_tag_,int _type_) |
633 | //{ |
634 | // return(0); |
635 | //} |
636 | |
637 | |
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 | const char *string The contents of the 'string' attribute (or NULL if not defined). |
664 | |
665 | const char *text The contents of the 'text' attribute (or NULL if not defined). |
666 | ++++++++++++++++++++++++++++++++++++++*/ |
667 | |
668 | static int CopyrightCreatorType_function(const char *_tag_,int _type_,const char *string,const char *text) |
669 | { |
670 | if(_type_&XMLPARSE_TAG_START && store) |
671 | { |
672 | char *xmlstring,*xmltext; |
673 | |
674 | XMLPARSE_ASSERT_STRING(_tag_,string); |
675 | XMLPARSE_ASSERT_STRING(_tag_,text); |
676 | |
677 | 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 | xmlstring=ParseXML_Encode_Safe_XML(string); |
681 | xmltext =ParseXML_Encode_Safe_XML(text); |
682 | |
683 | translate_xml_copyright_creator[0]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
684 | translate_xml_copyright_creator[1]=strcpy(malloc(strlen(xmltext)+1) ,xmltext); |
685 | } |
686 | |
687 | return(0); |
688 | } |
689 | |
690 | |
691 | /*++++++++++++++++++++++++++++++++++++++ |
692 | The function that is called when the CopyrightSourceType XSD type is seen |
693 | |
694 | int CopyrightSourceType_function Returns 0 if no error occured or something else otherwise. |
695 | |
696 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
697 | |
698 | 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 | const char *string The contents of the 'string' attribute (or NULL if not defined). |
701 | |
702 | 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 | const char *string The contents of the 'string' attribute (or NULL if not defined). |
738 | |
739 | const char *text The contents of the 'text' attribute (or NULL if not defined). |
740 | ++++++++++++++++++++++++++++++++++++++*/ |
741 | |
742 | static int CopyrightLicenseType_function(const char *_tag_,int _type_,const char *string,const char *text) |
743 | { |
744 | if(_type_&XMLPARSE_TAG_START && store) |
745 | { |
746 | char *xmlstring,*xmltext; |
747 | |
748 | XMLPARSE_ASSERT_STRING(_tag_,string); |
749 | XMLPARSE_ASSERT_STRING(_tag_,text); |
750 | |
751 | 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 | xmlstring=ParseXML_Encode_Safe_XML(string); |
755 | xmltext =ParseXML_Encode_Safe_XML(text); |
756 | |
757 | translate_xml_copyright_license[0]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
758 | translate_xml_copyright_license[1]=strcpy(malloc(strlen(xmltext)+1) ,xmltext); |
759 | } |
760 | |
761 | return(0); |
762 | } |
763 | |
764 | |
765 | /*++++++++++++++++++++++++++++++++++++++ |
766 | The function that is called when the HTMLWaypointType XSD type is seen |
767 | |
768 | int HTMLWaypointType_function Returns 0 if no error occured or something else otherwise. |
769 | |
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 | |
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 | ++++++++++++++++++++++++++++++++++++++*/ |
778 | |
779 | 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 | |
785 | XMLPARSE_ASSERT_STRING(_tag_,type); |
786 | XMLPARSE_ASSERT_STRING(_tag_,string); |
787 | |
788 | 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 | /*++++++++++++++++++++++++++++++++++++++ |
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 | char *xmltext; |
824 | |
825 | XMLPARSE_ASSERT_STRING(_tag_,text); |
826 | |
827 | xmltext=ParseXML_Encode_Safe_XML(text); |
828 | |
829 | translate_html_title=strcpy(malloc(strlen(xmltext)+1),xmltext); |
830 | } |
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 | char *xmlstring,*xmltext; |
855 | |
856 | XMLPARSE_ASSERT_STRING(_tag_,string); |
857 | XMLPARSE_ASSERT_STRING(_tag_,text); |
858 | |
859 | 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 | } |
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 | char *xmlstring,*xmltext; |
890 | |
891 | XMLPARSE_ASSERT_STRING(_tag_,string); |
892 | XMLPARSE_ASSERT_STRING(_tag_,text); |
893 | |
894 | 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 | } |
901 | |
902 | return(0); |
903 | } |
904 | |
905 | |
906 | /*++++++++++++++++++++++++++++++++++++++ |
907 | 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 | 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 | char *xmlstring,*xmltext; |
960 | const char *p; |
961 | char *q; |
962 | |
963 | XMLPARSE_ASSERT_STRING(_tag_,string); |
964 | XMLPARSE_ASSERT_STRING(_tag_,text); |
965 | |
966 | xmlstring=ParseXML_Encode_Safe_XML(string); |
967 | xmltext =ParseXML_Encode_Safe_XML(text); |
968 | |
969 | 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 | 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 | char *xmlstring,*xmltext; |
1013 | |
1014 | XMLPARSE_ASSERT_STRING(_tag_,string); |
1015 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1016 | |
1017 | 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 | } |
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 | char *xmlstring,*xmltext; |
1047 | |
1048 | XMLPARSE_ASSERT_STRING(_tag_,string); |
1049 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1050 | |
1051 | 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 | } |
1057 | |
1058 | return(0); |
1059 | } |
1060 | |
1061 | |
1062 | /*++++++++++++++++++++++++++++++++++++++ |
1063 | The function that is called when the GPXWaypointType XSD type is seen |
1064 | |
1065 | int GPXWaypointType_function Returns 0 if no error occured or something else otherwise. |
1066 | |
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 | |
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 | ++++++++++++++++++++++++++++++++++++++*/ |
1075 | |
1076 | 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 | |
1082 | XMLPARSE_ASSERT_STRING(_tag_,type); |
1083 | XMLPARSE_ASSERT_STRING(_tag_,string); |
1084 | |
1085 | 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 | /*++++++++++++++++++++++++++++++++++++++ |
1104 | The function that is called when the GPXDescType XSD type is seen |
1105 | |
1106 | int GPXDescType_function Returns 0 if no error occured or something else otherwise. |
1107 | |
1108 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
1109 | |
1110 | 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 | static int GPXDescType_function(const char *_tag_,int _type_,const char *text) |
1116 | { |
1117 | if(_type_&XMLPARSE_TAG_START && store) |
1118 | { |
1119 | char *xmltext; |
1120 | |
1121 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1122 | |
1123 | xmltext=ParseXML_Encode_Safe_XML(text); |
1124 | |
1125 | translate_gpx_desc=strcpy(malloc(strlen(xmltext)+1),xmltext); |
1126 | } |
1127 | |
1128 | return(0); |
1129 | } |
1130 | |
1131 | |
1132 | /*++++++++++++++++++++++++++++++++++++++ |
1133 | The function that is called when the GPXNameType XSD type is seen |
1134 | |
1135 | int GPXNameType_function Returns 0 if no error occured or something else otherwise. |
1136 | |
1137 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
1138 | |
1139 | 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 | static int GPXNameType_function(const char *_tag_,int _type_,const char *text) |
1145 | { |
1146 | if(_type_&XMLPARSE_TAG_START && store) |
1147 | { |
1148 | char *xmltext; |
1149 | |
1150 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1151 | |
1152 | xmltext=ParseXML_Encode_Safe_XML(text); |
1153 | |
1154 | translate_gpx_name=strcpy(malloc(strlen(xmltext)+1),xmltext); |
1155 | } |
1156 | |
1157 | return(0); |
1158 | } |
1159 | |
1160 | |
1161 | /*++++++++++++++++++++++++++++++++++++++ |
1162 | The function that is called when the GPXStepType XSD type is seen |
1163 | |
1164 | int GPXStepType_function Returns 0 if no error occured or something else otherwise. |
1165 | |
1166 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
1167 | |
1168 | 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 | static int GPXStepType_function(const char *_tag_,int _type_,const char *text) |
1174 | { |
1175 | if(_type_&XMLPARSE_TAG_START && store) |
1176 | { |
1177 | char *xmltext; |
1178 | |
1179 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1180 | |
1181 | xmltext=ParseXML_Encode_Safe_XML(text); |
1182 | |
1183 | translate_gpx_step=strcpy(malloc(strlen(xmltext)+1),xmltext); |
1184 | } |
1185 | |
1186 | return(0); |
1187 | } |
1188 | |
1189 | |
1190 | /*++++++++++++++++++++++++++++++++++++++ |
1191 | The function that is called when the GPXFinalType XSD type is seen |
1192 | |
1193 | int GPXFinalType_function Returns 0 if no error occured or something else otherwise. |
1194 | |
1195 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
1196 | |
1197 | 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 | static int GPXFinalType_function(const char *_tag_,int _type_,const char *text) |
1203 | { |
1204 | if(_type_&XMLPARSE_TAG_START && store) |
1205 | { |
1206 | char *xmltext; |
1207 | |
1208 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1209 | |
1210 | xmltext=ParseXML_Encode_Safe_XML(text); |
1211 | |
1212 | translate_gpx_final=strcpy(malloc(strlen(xmltext)+1),xmltext); |
1213 | } |
1214 | |
1215 | return(0); |
1216 | } |
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 | int fd; |
1232 | 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 | fd=ReOpenFile(filename); |
1243 | |
1244 | retval=ParseXML(fd,xml_toplevel_tags,XMLPARSE_UNKNOWN_ATTR_ERRNONAME|XMLPARSE_RETURN_ATTR_ENCODED); |
1245 | |
1246 | CloseFile(fd); |
1247 | |
1248 | if(retval) |
1249 | 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. |