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