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 1980 -
(hide annotations)
(download)
(as text)
Sun Apr 7 15:55:17 2019 UTC (5 years, 11 months ago) by amb
File MIME type: text/x-csrc
File size: 57170 byte(s)
Sun Apr 7 15:55:17 2019 UTC (5 years, 11 months ago) by amb
File MIME type: text/x-csrc
File size: 57170 byte(s)
Free some memory to avoid leaks - found by running with gcc's runtime sanitizer enabled (make SANITIZE=1 test).
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 | 1980 | This file Copyright 2010-2016, 2019 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 | 1784 | /* Default English translations - Must not require any UTF-8 encoding */ |
33 | amb | 361 | |
34 | amb | 1784 | static Translation default_translation= |
35 | { | ||
36 | amb | 1791 | .lang = "--", |
37 | .language = "English (built-in)", | ||
38 | amb | 361 | |
39 | amb | 1784 | .raw_copyright_creator = {"Creator","Routino - http://www.routino.org/"}, |
40 | .raw_copyright_source = {NULL,NULL}, | ||
41 | .raw_copyright_license = {NULL,NULL}, | ||
42 | amb | 375 | |
43 | amb | 1784 | .xml_copyright_creator = {"Creator","Routino - http://www.routino.org/"}, |
44 | .xml_copyright_source = {NULL,NULL}, | ||
45 | .xml_copyright_license = {NULL,NULL}, | ||
46 | amb | 361 | |
47 | amb | 1784 | .xml_heading = {"South","South-West","West","North-West","North","North-East","East","South-East","South"}, |
48 | .xml_turn = {"Very sharp left","Sharp left","Left","Slight left","Straight on","Slight right","Right","Sharp right","Very sharp right"}, | ||
49 | .xml_ordinal = {"First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth"}, | ||
50 | amb | 361 | |
51 | amb | 1784 | .notxml_heading = {"South","South-West","West","North-West","North","North-East","East","South-East","South"}, |
52 | .notxml_turn = {"Very sharp left","Sharp left","Left","Slight left","Straight on","Slight right","Right","Sharp right","Very sharp right"}, | ||
53 | .notxml_ordinal = {"First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth"}, | ||
54 | amb | 893 | |
55 | amb | 1784 | .raw_highway = {"","motorway","trunk road","primary road","secondary road","tertiary road","unclassified road","residential road","service road","track","cycleway","path","steps","ferry"}, |
56 | amb | 378 | |
57 | amb | 1784 | .xml_route_shortest = "Shortest", |
58 | .xml_route_quickest = "Quickest", | ||
59 | amb | 378 | |
60 | amb | 1815 | .html_waypoint = "Waypoint", |
61 | amb | 1784 | .html_junction = "Junction", |
62 | .html_roundabout = "Roundabout", | ||
63 | amb | 411 | |
64 | amb | 1784 | .html_title = "%s Route", |
65 | amb | 1894 | .html_start = "<tr class='n'><td>Start at %s, head <span class='b'>%s</span>\n", /* span tags added when reading XML translations file */ |
66 | .html_node = "<tr class='n'><td>At %s, go <span class='t'>%s</span> heading <span class='b'>%s</span>\n", /* span tags added when reading XML translations file */ | ||
67 | .html_rbnode = "<tr class='n'><td>Leave %s, take the <span class='b'>%s</span> exit heading <span class='b'>%s</span>\n", /* span tags added when reading XML translations file */ | ||
68 | .html_segment = "<tr class='s'><td>Follow <span class='h'>%s</span> for <span class='d'>%.3f km, %.1f min</span>", /* span tags added when reading XML translations file */ | ||
69 | .html_stop = "<tr class='n'><td>Stop at %s\n", | ||
70 | .html_total = "<tr class='t'><td><span class='j'>Total %.1f km, %.0f minutes</span>\n",/* span tags added when reading XML translations file */ | ||
71 | amb | 1784 | .html_subtotal= "<span class='j'>%.1f km, %.0f minutes</span>\n",/* span tag added when reading XML translations file */ |
72 | amb | 361 | |
73 | amb | 1784 | .nothtml_waypoint = "Waypoint", |
74 | .nothtml_junction = "Junction", | ||
75 | .nothtml_roundabout = "Roundabout", | ||
76 | amb | 361 | |
77 | amb | 1784 | .nothtml_title = "%s Route", |
78 | .nothtml_start = "Start at %s, head %s", | ||
79 | .nothtml_node = "At %s, go %s heading %s", | ||
80 | .nothtml_rbnode = "Leave %s, take the %s exit heading %s", | ||
81 | .nothtml_segment = "Follow %s for %.3f km, %.1f min", | ||
82 | .nothtml_stop = "Stop at %s", | ||
83 | .nothtml_total = "Total %.1f km, %.0f minutes", | ||
84 | .nothtml_subtotal= "%.1f km, %.0f minutes", | ||
85 | amb | 361 | |
86 | amb | 1784 | .gpx_desc = "%s route between 'start' and 'finish' waypoints", |
87 | .gpx_name = "%s route", | ||
88 | .gpx_step = "%s on '%s' for %.3f km, %.1f min", | ||
89 | .gpx_final = "Total Journey %.1f km, %.0f minutes", | ||
90 | amb | 361 | |
91 | amb | 1815 | .gpx_waypt = "WAYPT", |
92 | amb | 1784 | .gpx_trip = "TRIP", |
93 | }; | ||
94 | |||
95 | |||
96 | /* Local variables (re-intialised by FreeXMLTranslations() function) */ | ||
97 | |||
98 | /*+ The translations that have been loaded from file. +*/ | ||
99 | static Translation **loaded_translations=NULL; | ||
100 | |||
101 | /*+ The number of translations that have been loaded from file. +*/ | ||
102 | static int nloaded_translations=0; | ||
103 | |||
104 | |||
105 | /* Local variables (re-initialised for each file) */ | ||
106 | |||
107 | /*+ Store all of the translations. +*/ | ||
108 | static int store_all; | ||
109 | |||
110 | /*+ The translation language that is to be stored. +*/ | ||
111 | static const char *store_lang; | ||
112 | |||
113 | amb | 361 | /*+ This current language is to be stored. +*/ |
114 | amb | 1784 | static int store; |
115 | amb | 361 | |
116 | /*+ The chosen language has been stored. +*/ | ||
117 | amb | 1784 | static int stored; |
118 | amb | 361 | |
119 | |||
120 | /* The XML tag processing function prototypes */ | ||
121 | |||
122 | amb | 373 | //static int xmlDeclaration_function(const char *_tag_,int _type_,const char *version,const char *encoding); |
123 | //static int RoutinoTranslationsType_function(const char *_tag_,int _type_); | ||
124 | amb | 1791 | static int LanguageType_function(const char *_tag_,int _type_,const char *lang,const char *language); |
125 | amb | 1204 | //static int CopyrightType_function(const char *_tag_,int _type_); |
126 | static int TurnType_function(const char *_tag_,int _type_,const char *direction,const char *string); | ||
127 | static int HeadingType_function(const char *_tag_,int _type_,const char *direction,const char *string); | ||
128 | static int OrdinalType_function(const char *_tag_,int _type_,const char *number,const char *string); | ||
129 | static int HighwayType_function(const char *_tag_,int _type_,const char *type,const char *string); | ||
130 | static int RouteType_function(const char *_tag_,int _type_,const char *type,const char *string); | ||
131 | //static int HTMLType_function(const char *_tag_,int _type_); | ||
132 | amb | 373 | //static int GPXType_function(const char *_tag_,int _type_); |
133 | amb | 1204 | static int CopyrightCreatorType_function(const char *_tag_,int _type_,const char *string,const char *text); |
134 | static int CopyrightSourceType_function(const char *_tag_,int _type_,const char *string,const char *text); | ||
135 | static int CopyrightLicenseType_function(const char *_tag_,int _type_,const char *string,const char *text); | ||
136 | static int HTMLWaypointType_function(const char *_tag_,int _type_,const char *type,const char *string); | ||
137 | static int HTMLTitleType_function(const char *_tag_,int _type_,const char *text); | ||
138 | amb | 1796 | static int HTMLStartType_function(const char *_tag_,int _type_,const char *text); |
139 | static int HTMLNodeType_function(const char *_tag_,int _type_,const char *text); | ||
140 | static int HTMLRBNodeType_function(const char *_tag_,int _type_,const char *text); | ||
141 | static int HTMLSegmentType_function(const char *_tag_,int _type_,const char *text); | ||
142 | static int HTMLStopType_function(const char *_tag_,int _type_,const char *text); | ||
143 | static int HTMLTotalType_function(const char *_tag_,int _type_,const char *text); | ||
144 | static int HTMLSubtotalType_function(const char *_tag_,int _type_,const char *text); | ||
145 | amb | 373 | static int GPXWaypointType_function(const char *_tag_,int _type_,const char *type,const char *string); |
146 | amb | 1204 | static int GPXDescType_function(const char *_tag_,int _type_,const char *text); |
147 | static int GPXNameType_function(const char *_tag_,int _type_,const char *text); | ||
148 | static int GPXStepType_function(const char *_tag_,int _type_,const char *text); | ||
149 | static int GPXFinalType_function(const char *_tag_,int _type_,const char *text); | ||
150 | amb | 361 | |
151 | |||
152 | amb | 1204 | /* The XML tag definitions (forward declarations) */ |
153 | amb | 361 | |
154 | amb | 1719 | static const xmltag xmlDeclaration_tag; |
155 | static const xmltag RoutinoTranslationsType_tag; | ||
156 | static const xmltag LanguageType_tag; | ||
157 | static const xmltag CopyrightType_tag; | ||
158 | static const xmltag TurnType_tag; | ||
159 | static const xmltag HeadingType_tag; | ||
160 | static const xmltag OrdinalType_tag; | ||
161 | static const xmltag HighwayType_tag; | ||
162 | static const xmltag RouteType_tag; | ||
163 | static const xmltag HTMLType_tag; | ||
164 | static const xmltag GPXType_tag; | ||
165 | static const xmltag CopyrightCreatorType_tag; | ||
166 | static const xmltag CopyrightSourceType_tag; | ||
167 | static const xmltag CopyrightLicenseType_tag; | ||
168 | static const xmltag HTMLWaypointType_tag; | ||
169 | static const xmltag HTMLTitleType_tag; | ||
170 | static const xmltag HTMLStartType_tag; | ||
171 | static const xmltag HTMLNodeType_tag; | ||
172 | static const xmltag HTMLRBNodeType_tag; | ||
173 | static const xmltag HTMLSegmentType_tag; | ||
174 | static const xmltag HTMLStopType_tag; | ||
175 | static const xmltag HTMLTotalType_tag; | ||
176 | amb | 1796 | static const xmltag HTMLSubtotalType_tag; |
177 | amb | 1719 | static const xmltag GPXWaypointType_tag; |
178 | static const xmltag GPXDescType_tag; | ||
179 | static const xmltag GPXNameType_tag; | ||
180 | static const xmltag GPXStepType_tag; | ||
181 | static const xmltag GPXFinalType_tag; | ||
182 | amb | 375 | |
183 | |||
184 | amb | 1204 | /* The XML tag definition values */ |
185 | |||
186 | /*+ The complete set of tags at the top level. +*/ | ||
187 | amb | 1719 | static const xmltag * const xml_toplevel_tags[]={&xmlDeclaration_tag,&RoutinoTranslationsType_tag,NULL}; |
188 | amb | 1204 | |
189 | /*+ The xmlDeclaration type tag. +*/ | ||
190 | amb | 1719 | static const xmltag xmlDeclaration_tag= |
191 | amb | 1204 | {"xml", |
192 | 2, {"version","encoding"}, | ||
193 | NULL, | ||
194 | amb | 375 | {NULL}}; |
195 | |||
196 | amb | 1204 | /*+ The RoutinoTranslationsType type tag. +*/ |
197 | amb | 1719 | static const xmltag RoutinoTranslationsType_tag= |
198 | amb | 1204 | {"routino-translations", |
199 | 0, {NULL}, | ||
200 | NULL, | ||
201 | amb | 1205 | {&LanguageType_tag,NULL}}; |
202 | amb | 1204 | |
203 | amb | 1205 | /*+ The LanguageType type tag. +*/ |
204 | amb | 1719 | static const xmltag LanguageType_tag= |
205 | amb | 1204 | {"language", |
206 | amb | 1791 | 2, {"lang","language"}, |
207 | amb | 1205 | LanguageType_function, |
208 | amb | 1204 | {&CopyrightType_tag,&TurnType_tag,&HeadingType_tag,&OrdinalType_tag,&HighwayType_tag,&RouteType_tag,&HTMLType_tag,&GPXType_tag,NULL}}; |
209 | |||
210 | /*+ The CopyrightType type tag. +*/ | ||
211 | amb | 1719 | static const xmltag CopyrightType_tag= |
212 | amb | 1204 | {"copyright", |
213 | 0, {NULL}, | ||
214 | NULL, | ||
215 | {&CopyrightCreatorType_tag,&CopyrightSourceType_tag,&CopyrightLicenseType_tag,NULL}}; | ||
216 | |||
217 | amb | 361 | /*+ The TurnType type tag. +*/ |
218 | amb | 1719 | static const xmltag TurnType_tag= |
219 | amb | 361 | {"turn", |
220 | 2, {"direction","string"}, | ||
221 | amb | 367 | TurnType_function, |
222 | amb | 361 | {NULL}}; |
223 | |||
224 | /*+ The HeadingType type tag. +*/ | ||
225 | amb | 1719 | static const xmltag HeadingType_tag= |
226 | amb | 361 | {"heading", |
227 | 2, {"direction","string"}, | ||
228 | amb | 367 | HeadingType_function, |
229 | amb | 361 | {NULL}}; |
230 | |||
231 | amb | 925 | /*+ The OrdinalType type tag. +*/ |
232 | amb | 1719 | static const xmltag OrdinalType_tag= |
233 | amb | 925 | {"ordinal", |
234 | 2, {"number","string"}, | ||
235 | OrdinalType_function, | ||
236 | {NULL}}; | ||
237 | |||
238 | amb | 411 | /*+ The HighwayType type tag. +*/ |
239 | amb | 1719 | static const xmltag HighwayType_tag= |
240 | amb | 411 | {"highway", |
241 | 2, {"type","string"}, | ||
242 | HighwayType_function, | ||
243 | {NULL}}; | ||
244 | |||
245 | amb | 378 | /*+ The RouteType type tag. +*/ |
246 | amb | 1719 | static const xmltag RouteType_tag= |
247 | amb | 378 | {"route", |
248 | 2, {"type","string"}, | ||
249 | RouteType_function, | ||
250 | amb | 361 | {NULL}}; |
251 | |||
252 | amb | 1204 | /*+ The HTMLType type tag. +*/ |
253 | amb | 1719 | static const xmltag HTMLType_tag= |
254 | amb | 1204 | {"output-html", |
255 | 0, {NULL}, | ||
256 | NULL, | ||
257 | amb | 1796 | {&HTMLWaypointType_tag,&HTMLTitleType_tag,&HTMLStartType_tag,&HTMLNodeType_tag,&HTMLRBNodeType_tag,&HTMLSegmentType_tag,&HTMLStopType_tag,&HTMLTotalType_tag,&HTMLSubtotalType_tag,NULL}}; |
258 | amb | 1204 | |
259 | /*+ The GPXType type tag. +*/ | ||
260 | amb | 1719 | static const xmltag GPXType_tag= |
261 | amb | 1204 | {"output-gpx", |
262 | 0, {NULL}, | ||
263 | NULL, | ||
264 | {&GPXWaypointType_tag,&GPXDescType_tag,&GPXNameType_tag,&GPXStepType_tag,&GPXFinalType_tag,NULL}}; | ||
265 | |||
266 | /*+ The CopyrightCreatorType type tag. +*/ | ||
267 | amb | 1719 | static const xmltag CopyrightCreatorType_tag= |
268 | amb | 1204 | {"creator", |
269 | 2, {"string","text"}, | ||
270 | CopyrightCreatorType_function, | ||
271 | {NULL}}; | ||
272 | |||
273 | /*+ The CopyrightSourceType type tag. +*/ | ||
274 | amb | 1719 | static const xmltag CopyrightSourceType_tag= |
275 | amb | 1204 | {"source", |
276 | 2, {"string","text"}, | ||
277 | CopyrightSourceType_function, | ||
278 | {NULL}}; | ||
279 | |||
280 | /*+ The CopyrightLicenseType type tag. +*/ | ||
281 | amb | 1719 | static const xmltag CopyrightLicenseType_tag= |
282 | amb | 1204 | {"license", |
283 | 2, {"string","text"}, | ||
284 | CopyrightLicenseType_function, | ||
285 | {NULL}}; | ||
286 | |||
287 | amb | 378 | /*+ The HTMLWaypointType type tag. +*/ |
288 | amb | 1719 | static const xmltag HTMLWaypointType_tag= |
289 | amb | 378 | {"waypoint", |
290 | amb | 361 | 2, {"type","string"}, |
291 | amb | 378 | HTMLWaypointType_function, |
292 | amb | 361 | {NULL}}; |
293 | |||
294 | amb | 378 | /*+ The HTMLTitleType type tag. +*/ |
295 | amb | 1719 | static const xmltag HTMLTitleType_tag= |
296 | amb | 378 | {"title", |
297 | 1, {"text"}, | ||
298 | HTMLTitleType_function, | ||
299 | amb | 361 | {NULL}}; |
300 | |||
301 | amb | 378 | /*+ The HTMLStartType type tag. +*/ |
302 | amb | 1719 | static const xmltag HTMLStartType_tag= |
303 | amb | 378 | {"start", |
304 | amb | 1796 | 1, {"text"}, |
305 | amb | 378 | HTMLStartType_function, |
306 | {NULL}}; | ||
307 | |||
308 | /*+ The HTMLNodeType type tag. +*/ | ||
309 | amb | 1719 | static const xmltag HTMLNodeType_tag= |
310 | amb | 378 | {"node", |
311 | amb | 1796 | 1, {"text"}, |
312 | amb | 378 | HTMLNodeType_function, |
313 | {NULL}}; | ||
314 | |||
315 | amb | 925 | /*+ The HTMLRBNodeType type tag. +*/ |
316 | amb | 1719 | static const xmltag HTMLRBNodeType_tag= |
317 | amb | 925 | {"rbnode", |
318 | amb | 1796 | 1, {"text"}, |
319 | amb | 925 | HTMLRBNodeType_function, |
320 | {NULL}}; | ||
321 | |||
322 | amb | 378 | /*+ The HTMLSegmentType type tag. +*/ |
323 | amb | 1719 | static const xmltag HTMLSegmentType_tag= |
324 | amb | 378 | {"segment", |
325 | amb | 1796 | 1, {"text"}, |
326 | amb | 378 | HTMLSegmentType_function, |
327 | {NULL}}; | ||
328 | |||
329 | /*+ The HTMLStopType type tag. +*/ | ||
330 | amb | 1719 | static const xmltag HTMLStopType_tag= |
331 | amb | 378 | {"stop", |
332 | amb | 1796 | 1, {"text"}, |
333 | amb | 378 | HTMLStopType_function, |
334 | {NULL}}; | ||
335 | |||
336 | /*+ The HTMLTotalType type tag. +*/ | ||
337 | amb | 1719 | static const xmltag HTMLTotalType_tag= |
338 | amb | 378 | {"total", |
339 | amb | 1796 | 1, {"text"}, |
340 | amb | 378 | HTMLTotalType_function, |
341 | {NULL}}; | ||
342 | |||
343 | amb | 1796 | /*+ The HTMLSubtotalType type tag. +*/ |
344 | static const xmltag HTMLSubtotalType_tag= | ||
345 | {"subtotal", | ||
346 | 1, {"text"}, | ||
347 | HTMLSubtotalType_function, | ||
348 | {NULL}}; | ||
349 | |||
350 | amb | 1204 | /*+ The GPXWaypointType type tag. +*/ |
351 | amb | 1719 | static const xmltag GPXWaypointType_tag= |
352 | amb | 1204 | {"waypoint", |
353 | 2, {"type","string"}, | ||
354 | GPXWaypointType_function, | ||
355 | {NULL}}; | ||
356 | amb | 378 | |
357 | amb | 361 | /*+ The GPXDescType type tag. +*/ |
358 | amb | 1719 | static const xmltag GPXDescType_tag= |
359 | amb | 361 | {"desc", |
360 | 1, {"text"}, | ||
361 | amb | 367 | GPXDescType_function, |
362 | amb | 361 | {NULL}}; |
363 | |||
364 | /*+ The GPXNameType type tag. +*/ | ||
365 | amb | 1719 | static const xmltag GPXNameType_tag= |
366 | amb | 361 | {"name", |
367 | 1, {"text"}, | ||
368 | amb | 367 | GPXNameType_function, |
369 | amb | 361 | {NULL}}; |
370 | |||
371 | /*+ The GPXStepType type tag. +*/ | ||
372 | amb | 1719 | static const xmltag GPXStepType_tag= |
373 | amb | 361 | {"step", |
374 | 1, {"text"}, | ||
375 | amb | 367 | GPXStepType_function, |
376 | amb | 361 | {NULL}}; |
377 | |||
378 | /*+ The GPXFinalType type tag. +*/ | ||
379 | amb | 1719 | static const xmltag GPXFinalType_tag= |
380 | amb | 361 | {"final", |
381 | 1, {"text"}, | ||
382 | amb | 367 | GPXFinalType_function, |
383 | amb | 361 | {NULL}}; |
384 | |||
385 | |||
386 | /* The XML tag processing functions */ | ||
387 | |||
388 | |||
389 | /*++++++++++++++++++++++++++++++++++++++ | ||
390 | amb | 1204 | The function that is called when the XML declaration is seen |
391 | amb | 375 | |
392 | amb | 1204 | int xmlDeclaration_function Returns 0 if no error occured or something else otherwise. |
393 | amb | 375 | |
394 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
395 | |||
396 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
397 | |||
398 | amb | 1204 | const char *version The contents of the 'version' attribute (or NULL if not defined). |
399 | amb | 375 | |
400 | amb | 1204 | const char *encoding The contents of the 'encoding' attribute (or NULL if not defined). |
401 | amb | 375 | ++++++++++++++++++++++++++++++++++++++*/ |
402 | |||
403 | amb | 1204 | //static int xmlDeclaration_function(const char *_tag_,int _type_,const char *version,const char *encoding) |
404 | //{ | ||
405 | // return(0); | ||
406 | //} | ||
407 | amb | 486 | |
408 | amb | 375 | |
409 | amb | 1204 | /*++++++++++++++++++++++++++++++++++++++ |
410 | The function that is called when the RoutinoTranslationsType XSD type is seen | ||
411 | amb | 893 | |
412 | amb | 1204 | int RoutinoTranslationsType_function Returns 0 if no error occured or something else otherwise. |
413 | amb | 486 | |
414 | amb | 1204 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
415 | amb | 375 | |
416 | amb | 1204 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. |
417 | ++++++++++++++++++++++++++++++++++++++*/ | ||
418 | amb | 375 | |
419 | amb | 1204 | //static int RoutinoTranslationsType_function(const char *_tag_,int _type_) |
420 | //{ | ||
421 | // return(0); | ||
422 | //} | ||
423 | amb | 375 | |
424 | amb | 1204 | |
425 | amb | 375 | /*++++++++++++++++++++++++++++++++++++++ |
426 | amb | 1205 | The function that is called when the LanguageType XSD type is seen |
427 | amb | 375 | |
428 | amb | 1205 | int LanguageType_function Returns 0 if no error occured or something else otherwise. |
429 | amb | 375 | |
430 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
431 | |||
432 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
433 | |||
434 | amb | 1204 | const char *lang The contents of the 'lang' attribute (or NULL if not defined). |
435 | amb | 1791 | |
436 | const char *language The contents of the 'language' attribute (or NULL if not defined). | ||
437 | amb | 375 | ++++++++++++++++++++++++++++++++++++++*/ |
438 | |||
439 | amb | 1791 | static int LanguageType_function(const char *_tag_,int _type_,const char *lang,const char *language) |
440 | amb | 375 | { |
441 | amb | 1204 | if(_type_&XMLPARSE_TAG_START) |
442 | amb | 375 | { |
443 | amb | 1204 | XMLPARSE_ASSERT_STRING(_tag_,lang); |
444 | amb | 1791 | XMLPARSE_ASSERT_STRING(_tag_,language); |
445 | amb | 486 | |
446 | amb | 1784 | if(store_all) |
447 | amb | 1204 | store=1; |
448 | amb | 1784 | else if(!store_lang && !stored) |
449 | store=1; | ||
450 | amb | 1204 | else if(store_lang && !strcmp(store_lang,lang)) |
451 | store=1; | ||
452 | else | ||
453 | store=0; | ||
454 | amb | 375 | |
455 | amb | 1784 | if(store) |
456 | { | ||
457 | int i; | ||
458 | |||
459 | for(i=0;i<nloaded_translations;i++) | ||
460 | amb | 1791 | if(!strcmp(lang,loaded_translations[i]->lang)) |
461 | amb | 1784 | XMLPARSE_MESSAGE(_tag_,"translation name must be unique"); |
462 | |||
463 | if((nloaded_translations%16)==0) | ||
464 | loaded_translations=(Translation**)realloc((void*)loaded_translations,(nloaded_translations+16)*sizeof(Translation*)); | ||
465 | |||
466 | nloaded_translations++; | ||
467 | |||
468 | loaded_translations[nloaded_translations-1]=(Translation*)calloc(1,sizeof(Translation)); | ||
469 | |||
470 | *loaded_translations[nloaded_translations-1]=default_translation; | ||
471 | |||
472 | amb | 1791 | loaded_translations[nloaded_translations-1]->lang =strcpy(malloc(strlen(lang )+1),lang ); |
473 | loaded_translations[nloaded_translations-1]->language=strcpy(malloc(strlen(language)+1),language); | ||
474 | amb | 1784 | } |
475 | amb | 1204 | } |
476 | amb | 893 | |
477 | amb | 1204 | if(_type_&XMLPARSE_TAG_END && store) |
478 | { | ||
479 | store=0; | ||
480 | stored=1; | ||
481 | amb | 375 | } |
482 | |||
483 | return(0); | ||
484 | } | ||
485 | |||
486 | |||
487 | /*++++++++++++++++++++++++++++++++++++++ | ||
488 | amb | 1204 | The function that is called when the CopyrightType XSD type is seen |
489 | amb | 375 | |
490 | amb | 1204 | int CopyrightType_function Returns 0 if no error occured or something else otherwise. |
491 | amb | 375 | |
492 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
493 | |||
494 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
495 | ++++++++++++++++++++++++++++++++++++++*/ | ||
496 | |||
497 | amb | 1204 | //static int CopyrightType_function(const char *_tag_,int _type_) |
498 | //{ | ||
499 | // return(0); | ||
500 | //} | ||
501 | amb | 486 | |
502 | amb | 375 | |
503 | /*++++++++++++++++++++++++++++++++++++++ | ||
504 | amb | 361 | The function that is called when the TurnType XSD type is seen |
505 | |||
506 | amb | 367 | int TurnType_function Returns 0 if no error occured or something else otherwise. |
507 | amb | 363 | |
508 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
509 | |||
510 | 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. |
511 | |||
512 | const char *direction The contents of the 'direction' attribute (or NULL if not defined). | ||
513 | |||
514 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
515 | ++++++++++++++++++++++++++++++++++++++*/ | ||
516 | |||
517 | amb | 373 | static int TurnType_function(const char *_tag_,int _type_,const char *direction,const char *string) |
518 | amb | 361 | { |
519 | if(_type_&XMLPARSE_TAG_START && store) | ||
520 | { | ||
521 | amb | 486 | char *xmlstring; |
522 | amb | 361 | int d; |
523 | |||
524 | amb | 774 | XMLPARSE_ASSERT_INTEGER(_tag_,direction); d=atoi(direction); |
525 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,string); |
526 | amb | 361 | |
527 | amb | 363 | d+=4; |
528 | amb | 361 | |
529 | if(d<0 || d>8) | ||
530 | amb | 373 | XMLPARSE_INVALID(_tag_,direction); |
531 | amb | 361 | |
532 | amb | 1784 | loaded_translations[nloaded_translations-1]->notxml_turn[d]=strcpy(malloc(strlen(string)+1),string); |
533 | |||
534 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
535 | amb | 1784 | loaded_translations[nloaded_translations-1]->xml_turn[d]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
536 | amb | 361 | } |
537 | amb | 363 | |
538 | return(0); | ||
539 | amb | 361 | } |
540 | |||
541 | |||
542 | /*++++++++++++++++++++++++++++++++++++++ | ||
543 | The function that is called when the HeadingType XSD type is seen | ||
544 | |||
545 | amb | 367 | int HeadingType_function Returns 0 if no error occured or something else otherwise. |
546 | amb | 363 | |
547 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
548 | |||
549 | 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. |
550 | |||
551 | const char *direction The contents of the 'direction' attribute (or NULL if not defined). | ||
552 | |||
553 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
554 | ++++++++++++++++++++++++++++++++++++++*/ | ||
555 | |||
556 | amb | 373 | static int HeadingType_function(const char *_tag_,int _type_,const char *direction,const char *string) |
557 | amb | 361 | { |
558 | if(_type_&XMLPARSE_TAG_START && store) | ||
559 | { | ||
560 | amb | 486 | char *xmlstring; |
561 | amb | 361 | int d; |
562 | |||
563 | amb | 774 | XMLPARSE_ASSERT_INTEGER(_tag_,direction); d=atoi(direction); |
564 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,string); |
565 | amb | 361 | |
566 | amb | 363 | d+=4; |
567 | amb | 361 | |
568 | if(d<0 || d>8) | ||
569 | amb | 373 | XMLPARSE_INVALID(_tag_,direction); |
570 | amb | 361 | |
571 | amb | 1784 | loaded_translations[nloaded_translations-1]->notxml_heading[d]=strcpy(malloc(strlen(string)+1),string); |
572 | |||
573 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
574 | amb | 1784 | loaded_translations[nloaded_translations-1]->xml_heading[d]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
575 | amb | 361 | } |
576 | amb | 363 | |
577 | return(0); | ||
578 | amb | 361 | } |
579 | |||
580 | |||
581 | /*++++++++++++++++++++++++++++++++++++++ | ||
582 | amb | 925 | The function that is called when the OrdinalType XSD type is seen |
583 | |||
584 | int OrdinalType_function Returns 0 if no error occured or something else otherwise. | ||
585 | |||
586 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
587 | |||
588 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
589 | |||
590 | const char *number The contents of the 'number' attribute (or NULL if not defined). | ||
591 | |||
592 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
593 | ++++++++++++++++++++++++++++++++++++++*/ | ||
594 | |||
595 | static int OrdinalType_function(const char *_tag_,int _type_,const char *number,const char *string) | ||
596 | { | ||
597 | if(_type_&XMLPARSE_TAG_START && store) | ||
598 | { | ||
599 | char *xmlstring; | ||
600 | int n; | ||
601 | |||
602 | XMLPARSE_ASSERT_INTEGER(_tag_,number); n=atoi(number); | ||
603 | XMLPARSE_ASSERT_STRING(_tag_,string); | ||
604 | |||
605 | if(n<1 || n>10) | ||
606 | XMLPARSE_INVALID(_tag_,number); | ||
607 | |||
608 | amb | 1784 | loaded_translations[nloaded_translations-1]->notxml_ordinal[n-1]=strcpy(malloc(strlen(string)+1),string); |
609 | |||
610 | amb | 925 | xmlstring=ParseXML_Encode_Safe_XML(string); |
611 | amb | 1784 | loaded_translations[nloaded_translations-1]->xml_ordinal[n-1]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
612 | amb | 925 | } |
613 | |||
614 | return(0); | ||
615 | } | ||
616 | |||
617 | |||
618 | /*++++++++++++++++++++++++++++++++++++++ | ||
619 | amb | 411 | The function that is called when the HighwayType XSD type is seen |
620 | |||
621 | int HighwayType_function Returns 0 if no error occured or something else otherwise. | ||
622 | |||
623 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
624 | |||
625 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
626 | |||
627 | const char *type The contents of the 'type' attribute (or NULL if not defined). | ||
628 | |||
629 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
630 | ++++++++++++++++++++++++++++++++++++++*/ | ||
631 | |||
632 | static int HighwayType_function(const char *_tag_,int _type_,const char *type,const char *string) | ||
633 | { | ||
634 | if(_type_&XMLPARSE_TAG_START && store) | ||
635 | { | ||
636 | Highway highway; | ||
637 | |||
638 | XMLPARSE_ASSERT_STRING(_tag_,type); | ||
639 | XMLPARSE_ASSERT_STRING(_tag_,string); | ||
640 | |||
641 | highway=HighwayType(type); | ||
642 | |||
643 | amb | 1174 | if(highway==Highway_None) |
644 | amb | 411 | XMLPARSE_INVALID(_tag_,type); |
645 | |||
646 | amb | 1784 | loaded_translations[nloaded_translations-1]->raw_highway[highway]=strcpy(malloc(strlen(string)+1),string); |
647 | amb | 411 | } |
648 | |||
649 | return(0); | ||
650 | } | ||
651 | |||
652 | |||
653 | /*++++++++++++++++++++++++++++++++++++++ | ||
654 | amb | 378 | The function that is called when the RouteType XSD type is seen |
655 | amb | 363 | |
656 | amb | 378 | int RouteType_function Returns 0 if no error occured or something else otherwise. |
657 | amb | 363 | |
658 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
659 | |||
660 | 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. |
661 | |||
662 | amb | 361 | const char *type The contents of the 'type' attribute (or NULL if not defined). |
663 | |||
664 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
665 | ++++++++++++++++++++++++++++++++++++++*/ | ||
666 | |||
667 | amb | 378 | static int RouteType_function(const char *_tag_,int _type_,const char *type,const char *string) |
668 | amb | 361 | { |
669 | if(_type_&XMLPARSE_TAG_START && store) | ||
670 | { | ||
671 | amb | 486 | char *xmlstring; |
672 | |||
673 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,type); |
674 | XMLPARSE_ASSERT_STRING(_tag_,string); | ||
675 | amb | 361 | |
676 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
677 | |||
678 | amb | 361 | if(!strcmp(type,"shortest")) |
679 | amb | 1784 | loaded_translations[nloaded_translations-1]->xml_route_shortest=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
680 | amb | 361 | else if(!strcmp(type,"quickest")) |
681 | amb | 1784 | loaded_translations[nloaded_translations-1]->xml_route_quickest=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
682 | amb | 361 | else |
683 | amb | 373 | XMLPARSE_INVALID(_tag_,type); |
684 | amb | 361 | } |
685 | amb | 363 | |
686 | return(0); | ||
687 | amb | 361 | } |
688 | |||
689 | |||
690 | /*++++++++++++++++++++++++++++++++++++++ | ||
691 | amb | 1204 | The function that is called when the HTMLType XSD type is seen |
692 | amb | 375 | |
693 | amb | 1204 | int HTMLType_function Returns 0 if no error occured or something else otherwise. |
694 | amb | 375 | |
695 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
696 | |||
697 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
698 | amb | 1204 | ++++++++++++++++++++++++++++++++++++++*/ |
699 | amb | 378 | |
700 | amb | 1204 | //static int HTMLType_function(const char *_tag_,int _type_) |
701 | //{ | ||
702 | // return(0); | ||
703 | //} | ||
704 | amb | 378 | |
705 | amb | 1204 | |
706 | /*++++++++++++++++++++++++++++++++++++++ | ||
707 | The function that is called when the GPXType XSD type is seen | ||
708 | |||
709 | int GPXType_function Returns 0 if no error occured or something else otherwise. | ||
710 | |||
711 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
712 | |||
713 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
714 | ++++++++++++++++++++++++++++++++++++++*/ | ||
715 | |||
716 | //static int GPXType_function(const char *_tag_,int _type_) | ||
717 | //{ | ||
718 | // return(0); | ||
719 | //} | ||
720 | |||
721 | |||
722 | /*++++++++++++++++++++++++++++++++++++++ | ||
723 | The function that is called when the CopyrightCreatorType XSD type is seen | ||
724 | |||
725 | int CopyrightCreatorType_function Returns 0 if no error occured or something else otherwise. | ||
726 | |||
727 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
728 | |||
729 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
730 | |||
731 | amb | 378 | const char *string The contents of the 'string' attribute (or NULL if not defined). |
732 | amb | 1204 | |
733 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
734 | amb | 375 | ++++++++++++++++++++++++++++++++++++++*/ |
735 | |||
736 | amb | 1204 | static int CopyrightCreatorType_function(const char *_tag_,int _type_,const char *string,const char *text) |
737 | amb | 378 | { |
738 | if(_type_&XMLPARSE_TAG_START && store) | ||
739 | { | ||
740 | amb | 1204 | char *xmlstring,*xmltext; |
741 | amb | 486 | |
742 | amb | 378 | XMLPARSE_ASSERT_STRING(_tag_,string); |
743 | amb | 1204 | XMLPARSE_ASSERT_STRING(_tag_,text); |
744 | amb | 375 | |
745 | amb | 1784 | loaded_translations[nloaded_translations-1]->raw_copyright_creator[0]=strcpy(malloc(strlen(string)+1),string); |
746 | loaded_translations[nloaded_translations-1]->raw_copyright_creator[1]=strcpy(malloc(strlen(text)+1) ,text); | ||
747 | amb | 1204 | |
748 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
749 | amb | 1784 | loaded_translations[nloaded_translations-1]->xml_copyright_creator[0]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
750 | amb | 486 | |
751 | amb | 1784 | xmltext=ParseXML_Encode_Safe_XML(text); |
752 | loaded_translations[nloaded_translations-1]->xml_copyright_creator[1]=strcpy(malloc(strlen(xmltext)+1),xmltext); | ||
753 | amb | 378 | } |
754 | amb | 375 | |
755 | amb | 378 | return(0); |
756 | } | ||
757 | |||
758 | |||
759 | amb | 375 | /*++++++++++++++++++++++++++++++++++++++ |
760 | amb | 1204 | The function that is called when the CopyrightSourceType XSD type is seen |
761 | amb | 361 | |
762 | amb | 1204 | int CopyrightSourceType_function Returns 0 if no error occured or something else otherwise. |
763 | amb | 363 | |
764 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
765 | |||
766 | 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. |
767 | |||
768 | amb | 1204 | const char *string The contents of the 'string' attribute (or NULL if not defined). |
769 | amb | 361 | |
770 | amb | 1204 | const char *text The contents of the 'text' attribute (or NULL if not defined). |
771 | ++++++++++++++++++++++++++++++++++++++*/ | ||
772 | |||
773 | static int CopyrightSourceType_function(const char *_tag_,int _type_,const char *string,const char *text) | ||
774 | { | ||
775 | if(_type_&XMLPARSE_TAG_START && store) | ||
776 | { | ||
777 | char *xmlstring,*xmltext; | ||
778 | |||
779 | XMLPARSE_ASSERT_STRING(_tag_,string); | ||
780 | XMLPARSE_ASSERT_STRING(_tag_,text); | ||
781 | |||
782 | amb | 1784 | loaded_translations[nloaded_translations-1]->raw_copyright_source[0]=strcpy(malloc(strlen(string)+1),string); |
783 | loaded_translations[nloaded_translations-1]->raw_copyright_source[1]=strcpy(malloc(strlen(text)+1) ,text); | ||
784 | amb | 1204 | |
785 | xmlstring=ParseXML_Encode_Safe_XML(string); | ||
786 | amb | 1784 | loaded_translations[nloaded_translations-1]->xml_copyright_source[0]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
787 | amb | 1204 | |
788 | amb | 1784 | xmltext=ParseXML_Encode_Safe_XML(text); |
789 | loaded_translations[nloaded_translations-1]->xml_copyright_source[1]=strcpy(malloc(strlen(xmltext)+1),xmltext); | ||
790 | amb | 1204 | } |
791 | |||
792 | return(0); | ||
793 | } | ||
794 | |||
795 | |||
796 | /*++++++++++++++++++++++++++++++++++++++ | ||
797 | The function that is called when the CopyrightLicenseType XSD type is seen | ||
798 | |||
799 | int CopyrightLicenseType_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 | amb | 361 | const char *string The contents of the 'string' attribute (or NULL if not defined). |
806 | amb | 1204 | |
807 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
808 | amb | 361 | ++++++++++++++++++++++++++++++++++++++*/ |
809 | |||
810 | amb | 1204 | static int CopyrightLicenseType_function(const char *_tag_,int _type_,const char *string,const char *text) |
811 | amb | 361 | { |
812 | if(_type_&XMLPARSE_TAG_START && store) | ||
813 | { | ||
814 | amb | 1204 | char *xmlstring,*xmltext; |
815 | amb | 486 | |
816 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,string); |
817 | amb | 1204 | XMLPARSE_ASSERT_STRING(_tag_,text); |
818 | amb | 361 | |
819 | amb | 1784 | loaded_translations[nloaded_translations-1]->raw_copyright_license[0]=strcpy(malloc(strlen(string)+1),string); |
820 | loaded_translations[nloaded_translations-1]->raw_copyright_license[1]=strcpy(malloc(strlen(text)+1) ,text); | ||
821 | amb | 1204 | |
822 | amb | 486 | xmlstring=ParseXML_Encode_Safe_XML(string); |
823 | amb | 1784 | loaded_translations[nloaded_translations-1]->xml_copyright_license[0]=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
824 | amb | 486 | |
825 | amb | 1784 | xmltext=ParseXML_Encode_Safe_XML(text); |
826 | loaded_translations[nloaded_translations-1]->xml_copyright_license[1]=strcpy(malloc(strlen(xmltext)+1),xmltext); | ||
827 | amb | 361 | } |
828 | amb | 363 | |
829 | return(0); | ||
830 | amb | 361 | } |
831 | |||
832 | |||
833 | /*++++++++++++++++++++++++++++++++++++++ | ||
834 | amb | 1204 | The function that is called when the HTMLWaypointType XSD type is seen |
835 | amb | 378 | |
836 | amb | 1204 | int HTMLWaypointType_function Returns 0 if no error occured or something else otherwise. |
837 | amb | 378 | |
838 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
839 | |||
840 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
841 | amb | 1204 | |
842 | const char *type The contents of the 'type' attribute (or NULL if not defined). | ||
843 | |||
844 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
845 | amb | 378 | ++++++++++++++++++++++++++++++++++++++*/ |
846 | |||
847 | amb | 1204 | static int HTMLWaypointType_function(const char *_tag_,int _type_,const char *type,const char *string) |
848 | { | ||
849 | if(_type_&XMLPARSE_TAG_START && store) | ||
850 | { | ||
851 | char *xmlstring; | ||
852 | amb | 378 | |
853 | amb | 1204 | XMLPARSE_ASSERT_STRING(_tag_,type); |
854 | XMLPARSE_ASSERT_STRING(_tag_,string); | ||
855 | amb | 378 | |
856 | amb | 1204 | xmlstring=ParseXML_Encode_Safe_XML(string); |
857 | |||
858 | if(!strcmp(type,"waypoint")) | ||
859 | { | ||
860 | amb | 1784 | loaded_translations[nloaded_translations-1]->nothtml_waypoint=strcpy(malloc(strlen(string)+1),string); |
861 | |||
862 | amb | 1815 | loaded_translations[nloaded_translations-1]->html_waypoint=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
863 | amb | 1204 | } |
864 | else if(!strcmp(type,"junction")) | ||
865 | amb | 1784 | { |
866 | loaded_translations[nloaded_translations-1]->nothtml_junction=strcpy(malloc(strlen(string)+1),string); | ||
867 | |||
868 | loaded_translations[nloaded_translations-1]->html_junction=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
869 | } | ||
870 | amb | 1204 | else if(!strcmp(type,"roundabout")) |
871 | amb | 1784 | { |
872 | loaded_translations[nloaded_translations-1]->nothtml_roundabout=strcpy(malloc(strlen(string)+1),string); | ||
873 | |||
874 | loaded_translations[nloaded_translations-1]->html_roundabout=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
875 | } | ||
876 | amb | 1204 | else |
877 | XMLPARSE_INVALID(_tag_,type); | ||
878 | } | ||
879 | |||
880 | return(0); | ||
881 | } | ||
882 | |||
883 | |||
884 | amb | 378 | /*++++++++++++++++++++++++++++++++++++++ |
885 | The function that is called when the HTMLTitleType XSD type is seen | ||
886 | |||
887 | int HTMLTitleType_function Returns 0 if no error occured or something else otherwise. | ||
888 | |||
889 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
890 | |||
891 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
892 | |||
893 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
894 | ++++++++++++++++++++++++++++++++++++++*/ | ||
895 | |||
896 | static int HTMLTitleType_function(const char *_tag_,int _type_,const char *text) | ||
897 | { | ||
898 | if(_type_&XMLPARSE_TAG_START && store) | ||
899 | { | ||
900 | amb | 486 | char *xmltext; |
901 | |||
902 | amb | 378 | XMLPARSE_ASSERT_STRING(_tag_,text); |
903 | |||
904 | amb | 1796 | xmltext=ParseXML_Encode_Safe_XML(text); |
905 | |||
906 | amb | 1784 | loaded_translations[nloaded_translations-1]->nothtml_title=strcpy(malloc(strlen(text)+1),text); |
907 | |||
908 | loaded_translations[nloaded_translations-1]->html_title=strcpy(malloc(strlen(xmltext)+1),xmltext); | ||
909 | amb | 378 | } |
910 | |||
911 | return(0); | ||
912 | } | ||
913 | |||
914 | |||
915 | /*++++++++++++++++++++++++++++++++++++++ | ||
916 | The function that is called when the HTMLStartType XSD type is seen | ||
917 | |||
918 | int HTMLStartType_function Returns 0 if no error occured or something else otherwise. | ||
919 | |||
920 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
921 | |||
922 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
923 | |||
924 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
925 | ++++++++++++++++++++++++++++++++++++++*/ | ||
926 | |||
927 | amb | 1796 | static int HTMLStartType_function(const char *_tag_,int _type_,const char *text) |
928 | amb | 378 | { |
929 | if(_type_&XMLPARSE_TAG_START && store) | ||
930 | { | ||
931 | amb | 1796 | char *xmltext; |
932 | amb | 1784 | const char *p; |
933 | char *q; | ||
934 | amb | 486 | |
935 | amb | 378 | XMLPARSE_ASSERT_STRING(_tag_,text); |
936 | |||
937 | amb | 1796 | xmltext=ParseXML_Encode_Safe_XML(text); |
938 | amb | 1784 | |
939 | amb | 1796 | loaded_translations[nloaded_translations-1]->nothtml_start=strcpy(malloc(strlen(text)+1),text); |
940 | amb | 486 | |
941 | amb | 1796 | loaded_translations[nloaded_translations-1]->html_start=malloc(sizeof("<tr class='n'><td>")+strlen(xmltext)+sizeof("<span class='b'>")+sizeof("</span>")+1+1); |
942 | amb | 1784 | |
943 | p=xmltext; | ||
944 | amb | 1796 | q=loaded_translations[nloaded_translations-1]->html_start; |
945 | amb | 1784 | |
946 | amb | 1796 | strcpy(q,"<tr class='n'><td>"); q+=sizeof("<tr class='n'><td>")-1; |
947 | |||
948 | amb | 1784 | while(*p!='%') |
949 | *q++=*p++; | ||
950 | |||
951 | *q++=*p++; | ||
952 | |||
953 | while(*p!='%') | ||
954 | *q++=*p++; | ||
955 | |||
956 | p+=2; | ||
957 | strcpy(q,"<span class='b'>%s</span>"); q+=sizeof("<span class='b'>%s</span>")-1; | ||
958 | |||
959 | strcpy(q,p); | ||
960 | strcat(q,"\n"); | ||
961 | amb | 378 | } |
962 | |||
963 | return(0); | ||
964 | } | ||
965 | |||
966 | |||
967 | /*++++++++++++++++++++++++++++++++++++++ | ||
968 | The function that is called when the HTMLNodeType XSD type is seen | ||
969 | |||
970 | int HTMLNodeType_function Returns 0 if no error occured or something else otherwise. | ||
971 | |||
972 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
973 | |||
974 | 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 | 1796 | static int HTMLNodeType_function(const char *_tag_,int _type_,const char *text) |
980 | amb | 378 | { |
981 | if(_type_&XMLPARSE_TAG_START && store) | ||
982 | { | ||
983 | amb | 1796 | char *xmltext; |
984 | amb | 1784 | const char *p; |
985 | char *q; | ||
986 | amb | 486 | |
987 | amb | 378 | XMLPARSE_ASSERT_STRING(_tag_,text); |
988 | |||
989 | amb | 1796 | xmltext=ParseXML_Encode_Safe_XML(text); |
990 | amb | 1784 | |
991 | amb | 1796 | loaded_translations[nloaded_translations-1]->nothtml_node=strcpy(malloc(strlen(text)+1),text); |
992 | amb | 486 | |
993 | amb | 1796 | loaded_translations[nloaded_translations-1]->html_node=malloc(sizeof("<tr class='n'><td>")+strlen(xmltext)+2*sizeof("<span class='b'>")+2*sizeof("</span>")+1+1); |
994 | amb | 1784 | |
995 | p=xmltext; | ||
996 | amb | 1796 | q=loaded_translations[nloaded_translations-1]->html_node; |
997 | amb | 1784 | |
998 | amb | 1796 | strcpy(q,"<tr class='n'><td>"); q+=sizeof("<tr class='n'><td>")-1; |
999 | |||
1000 | amb | 1784 | while(*p!='%') |
1001 | *q++=*p++; | ||
1002 | |||
1003 | *q++=*p++; | ||
1004 | |||
1005 | while(*p!='%') | ||
1006 | *q++=*p++; | ||
1007 | |||
1008 | p+=2; | ||
1009 | strcpy(q,"<span class='t'>%s</span>"); q+=sizeof("<span class='t'>%s</span>")-1; | ||
1010 | |||
1011 | while(*p!='%') | ||
1012 | *q++=*p++; | ||
1013 | |||
1014 | p+=2; | ||
1015 | strcpy(q,"<span class='b'>%s</span>"); q+=sizeof("<span class='b'>%s</span>")-1; | ||
1016 | |||
1017 | strcpy(q,p); | ||
1018 | strcat(q,"\n"); | ||
1019 | amb | 378 | } |
1020 | |||
1021 | return(0); | ||
1022 | } | ||
1023 | |||
1024 | |||
1025 | /*++++++++++++++++++++++++++++++++++++++ | ||
1026 | amb | 925 | The function that is called when the HTMLRBNodeType XSD type is seen |
1027 | |||
1028 | int HTMLRBNodeType_function Returns 0 if no error occured or something else otherwise. | ||
1029 | |||
1030 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
1031 | |||
1032 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
1033 | |||
1034 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1035 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1036 | |||
1037 | amb | 1796 | static int HTMLRBNodeType_function(const char *_tag_,int _type_,const char *text) |
1038 | amb | 925 | { |
1039 | if(_type_&XMLPARSE_TAG_START && store) | ||
1040 | { | ||
1041 | amb | 1796 | char *xmltext; |
1042 | amb | 1784 | const char *p; |
1043 | char *q; | ||
1044 | amb | 925 | |
1045 | XMLPARSE_ASSERT_STRING(_tag_,text); | ||
1046 | |||
1047 | amb | 1796 | xmltext=ParseXML_Encode_Safe_XML(text); |
1048 | amb | 1784 | |
1049 | amb | 1796 | loaded_translations[nloaded_translations-1]->nothtml_rbnode=strcpy(malloc(strlen(text)+1),text); |
1050 | amb | 925 | |
1051 | amb | 1796 | loaded_translations[nloaded_translations-1]->html_rbnode=malloc(sizeof("<tr class='n'><td>")+strlen(xmltext)+2*sizeof("<span class='b'>")+2*sizeof("</span>")+1+1); |
1052 | amb | 1784 | |
1053 | p=xmltext; | ||
1054 | amb | 1796 | q=loaded_translations[nloaded_translations-1]->html_rbnode; |
1055 | amb | 1784 | |
1056 | amb | 1796 | strcpy(q,"<tr class='n'><td>"); q+=sizeof("<tr class='n'><td>")-1; |
1057 | |||
1058 | amb | 1784 | while(*p!='%') |
1059 | *q++=*p++; | ||
1060 | |||
1061 | *q++=*p++; | ||
1062 | |||
1063 | while(*p!='%') | ||
1064 | *q++=*p++; | ||
1065 | |||
1066 | p+=2; | ||
1067 | strcpy(q,"<span class='t'>%s</span>"); q+=sizeof("<span class='t'>%s</span>")-1; | ||
1068 | |||
1069 | while(*p!='%') | ||
1070 | *q++=*p++; | ||
1071 | |||
1072 | p+=2; | ||
1073 | strcpy(q,"<span class='b'>%s</span>"); q+=sizeof("<span class='b'>%s</span>")-1; | ||
1074 | |||
1075 | strcpy(q,p); | ||
1076 | strcat(q,"\n"); | ||
1077 | amb | 925 | } |
1078 | |||
1079 | return(0); | ||
1080 | } | ||
1081 | |||
1082 | |||
1083 | /*++++++++++++++++++++++++++++++++++++++ | ||
1084 | amb | 378 | The function that is called when the HTMLSegmentType XSD type is seen |
1085 | |||
1086 | int HTMLSegmentType_function Returns 0 if no error occured or something else otherwise. | ||
1087 | |||
1088 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
1089 | |||
1090 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
1091 | |||
1092 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1093 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1094 | |||
1095 | amb | 1796 | static int HTMLSegmentType_function(const char *_tag_,int _type_,const char *text) |
1096 | amb | 378 | { |
1097 | if(_type_&XMLPARSE_TAG_START && store) | ||
1098 | { | ||
1099 | amb | 1796 | char *xmltext; |
1100 | amb | 378 | const char *p; |
1101 | char *q; | ||
1102 | |||
1103 | XMLPARSE_ASSERT_STRING(_tag_,text); | ||
1104 | |||
1105 | amb | 1796 | xmltext=ParseXML_Encode_Safe_XML(text); |
1106 | amb | 1784 | |
1107 | amb | 1796 | loaded_translations[nloaded_translations-1]->nothtml_segment=strcpy(malloc(strlen(text)+1),text); |
1108 | amb | 378 | |
1109 | amb | 1796 | loaded_translations[nloaded_translations-1]->html_segment=malloc(sizeof("<tr class='s'><td>")+strlen(xmltext)+2*sizeof("<span class='b'>")+2*sizeof("</span>")+1); |
1110 | amb | 486 | |
1111 | p=xmltext; | ||
1112 | amb | 1796 | q=loaded_translations[nloaded_translations-1]->html_segment; |
1113 | amb | 378 | |
1114 | amb | 1796 | strcpy(q,"<tr class='s'><td>"); q+=sizeof("<tr class='s'><td>")-1; |
1115 | |||
1116 | amb | 1784 | while(*p!='%') |
1117 | amb | 378 | *q++=*p++; |
1118 | |||
1119 | p+=2; | ||
1120 | strcpy(q,"<span class='h'>%s</span>"); q+=sizeof("<span class='h'>%s</span>")-1; | ||
1121 | |||
1122 | while(*p!='%') | ||
1123 | *q++=*p++; | ||
1124 | |||
1125 | strcpy(q,"<span class='d'>"); q+=sizeof("<span class='d'>")-1; | ||
1126 | |||
1127 | strcpy(q,p); | ||
1128 | strcat(q,"</span>"); | ||
1129 | } | ||
1130 | |||
1131 | return(0); | ||
1132 | } | ||
1133 | |||
1134 | |||
1135 | /*++++++++++++++++++++++++++++++++++++++ | ||
1136 | The function that is called when the HTMLStopType XSD type is seen | ||
1137 | |||
1138 | int HTMLStopType_function Returns 0 if no error occured or something else otherwise. | ||
1139 | |||
1140 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
1141 | |||
1142 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
1143 | |||
1144 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1145 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1146 | |||
1147 | amb | 1796 | static int HTMLStopType_function(const char *_tag_,int _type_,const char *text) |
1148 | amb | 378 | { |
1149 | if(_type_&XMLPARSE_TAG_START && store) | ||
1150 | { | ||
1151 | amb | 1796 | char *xmltext; |
1152 | amb | 486 | |
1153 | amb | 378 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1154 | |||
1155 | amb | 1796 | xmltext=ParseXML_Encode_Safe_XML(text); |
1156 | amb | 1784 | |
1157 | amb | 1796 | loaded_translations[nloaded_translations-1]->nothtml_stop=strcpy(malloc(strlen(text)+1),text); |
1158 | amb | 486 | |
1159 | amb | 1796 | loaded_translations[nloaded_translations-1]->html_stop=malloc(sizeof("<tr class='n'><td>")+strlen(xmltext)+1+1); |
1160 | amb | 1784 | |
1161 | amb | 1796 | strcpy(loaded_translations[nloaded_translations-1]->html_stop,"<tr class='n'><td>"); |
1162 | amb | 1784 | strcat(loaded_translations[nloaded_translations-1]->html_stop,xmltext); |
1163 | strcat(loaded_translations[nloaded_translations-1]->html_stop,"\n"); | ||
1164 | amb | 378 | } |
1165 | |||
1166 | return(0); | ||
1167 | } | ||
1168 | |||
1169 | |||
1170 | /*++++++++++++++++++++++++++++++++++++++ | ||
1171 | The function that is called when the HTMLTotalType XSD type is seen | ||
1172 | |||
1173 | int HTMLTotalType_function Returns 0 if no error occured or something else otherwise. | ||
1174 | |||
1175 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
1176 | |||
1177 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
1178 | |||
1179 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1180 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1181 | |||
1182 | amb | 1796 | static int HTMLTotalType_function(const char *_tag_,int _type_,const char *text) |
1183 | amb | 378 | { |
1184 | if(_type_&XMLPARSE_TAG_START && store) | ||
1185 | { | ||
1186 | amb | 1796 | char *xmltext; |
1187 | amb | 486 | |
1188 | amb | 378 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1189 | |||
1190 | amb | 1796 | xmltext=ParseXML_Encode_Safe_XML(text); |
1191 | amb | 1784 | |
1192 | amb | 1796 | loaded_translations[nloaded_translations-1]->nothtml_total=strcpy(malloc(strlen(text)+1),text); |
1193 | amb | 486 | |
1194 | amb | 1796 | loaded_translations[nloaded_translations-1]->html_total=malloc(sizeof("<tr class='t'><td>")+strlen(xmltext)+sizeof("<span class='j'>")+sizeof("</span>")+1+1); |
1195 | amb | 1784 | |
1196 | amb | 1796 | strcpy(loaded_translations[nloaded_translations-1]->html_total,"<tr class='t'><td>"); |
1197 | amb | 1784 | strcat(loaded_translations[nloaded_translations-1]->html_total,"<span class='j'>"); |
1198 | strcat(loaded_translations[nloaded_translations-1]->html_total,xmltext); | ||
1199 | strcat(loaded_translations[nloaded_translations-1]->html_total,"</span>"); | ||
1200 | strcat(loaded_translations[nloaded_translations-1]->html_total,"\n"); | ||
1201 | amb | 1796 | } |
1202 | amb | 1784 | |
1203 | amb | 1796 | return(0); |
1204 | } | ||
1205 | amb | 1784 | |
1206 | amb | 1796 | |
1207 | /*++++++++++++++++++++++++++++++++++++++ | ||
1208 | The function that is called when the HTMLSubtotalType XSD type is seen | ||
1209 | |||
1210 | int HTMLSubtotalType_function Returns 0 if no error occured or something else otherwise. | ||
1211 | |||
1212 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
1213 | |||
1214 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
1215 | |||
1216 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1217 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1218 | |||
1219 | static int HTMLSubtotalType_function(const char *_tag_,int _type_,const char *text) | ||
1220 | { | ||
1221 | if(_type_&XMLPARSE_TAG_START && store) | ||
1222 | { | ||
1223 | char *xmltext; | ||
1224 | |||
1225 | XMLPARSE_ASSERT_STRING(_tag_,text); | ||
1226 | |||
1227 | xmltext=ParseXML_Encode_Safe_XML(text); | ||
1228 | |||
1229 | amb | 1784 | loaded_translations[nloaded_translations-1]->nothtml_subtotal=strcpy(malloc(strlen(text)+1),text); |
1230 | |||
1231 | loaded_translations[nloaded_translations-1]->html_subtotal=malloc(sizeof(" [<span class='j'>")+strlen(xmltext)+sizeof("</span>]")+1+1); | ||
1232 | |||
1233 | strcpy(loaded_translations[nloaded_translations-1]->html_subtotal," [<span class='j'>"); | ||
1234 | strcat(loaded_translations[nloaded_translations-1]->html_subtotal,xmltext); | ||
1235 | strcat(loaded_translations[nloaded_translations-1]->html_subtotal,"</span>]"); | ||
1236 | strcat(loaded_translations[nloaded_translations-1]->html_subtotal,"\n"); | ||
1237 | amb | 378 | } |
1238 | |||
1239 | return(0); | ||
1240 | } | ||
1241 | |||
1242 | |||
1243 | /*++++++++++++++++++++++++++++++++++++++ | ||
1244 | amb | 1204 | The function that is called when the GPXWaypointType XSD type is seen |
1245 | amb | 378 | |
1246 | amb | 1204 | int GPXWaypointType_function Returns 0 if no error occured or something else otherwise. |
1247 | amb | 378 | |
1248 | const char *_tag_ Set to the name of the element tag that triggered this function call. | ||
1249 | |||
1250 | int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. | ||
1251 | amb | 1204 | |
1252 | const char *type The contents of the 'type' attribute (or NULL if not defined). | ||
1253 | |||
1254 | const char *string The contents of the 'string' attribute (or NULL if not defined). | ||
1255 | amb | 378 | ++++++++++++++++++++++++++++++++++++++*/ |
1256 | |||
1257 | amb | 1204 | static int GPXWaypointType_function(const char *_tag_,int _type_,const char *type,const char *string) |
1258 | { | ||
1259 | if(_type_&XMLPARSE_TAG_START && store) | ||
1260 | { | ||
1261 | char *xmlstring; | ||
1262 | amb | 378 | |
1263 | amb | 1204 | XMLPARSE_ASSERT_STRING(_tag_,type); |
1264 | XMLPARSE_ASSERT_STRING(_tag_,string); | ||
1265 | amb | 378 | |
1266 | amb | 1204 | xmlstring=ParseXML_Encode_Safe_XML(string); |
1267 | |||
1268 | amb | 1815 | if(!strcmp(type,"waypt")) |
1269 | loaded_translations[nloaded_translations-1]->gpx_waypt=strcpy(malloc(strlen(xmlstring)+1),xmlstring); | ||
1270 | amb | 1204 | else if(!strcmp(type,"trip")) |
1271 | amb | 1784 | loaded_translations[nloaded_translations-1]->gpx_trip=strcpy(malloc(strlen(xmlstring)+1),xmlstring); |
1272 | amb | 1204 | else |
1273 | XMLPARSE_INVALID(_tag_,type); | ||
1274 | } | ||
1275 | |||
1276 | return(0); | ||
1277 | } | ||
1278 | |||
1279 | |||
1280 | amb | 378 | /*++++++++++++++++++++++++++++++++++++++ |
1281 | amb | 361 | The function that is called when the GPXDescType XSD type is seen |
1282 | |||
1283 | amb | 367 | int GPXDescType_function Returns 0 if no error occured or something else otherwise. |
1284 | amb | 363 | |
1285 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
1286 | |||
1287 | 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. |
1288 | |||
1289 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1290 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1291 | |||
1292 | amb | 373 | static int GPXDescType_function(const char *_tag_,int _type_,const char *text) |
1293 | amb | 361 | { |
1294 | if(_type_&XMLPARSE_TAG_START && store) | ||
1295 | { | ||
1296 | amb | 486 | char *xmltext; |
1297 | |||
1298 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1299 | amb | 361 | |
1300 | amb | 486 | xmltext=ParseXML_Encode_Safe_XML(text); |
1301 | amb | 1784 | loaded_translations[nloaded_translations-1]->gpx_desc=strcpy(malloc(strlen(xmltext)+1),xmltext); |
1302 | amb | 361 | } |
1303 | amb | 363 | |
1304 | return(0); | ||
1305 | amb | 361 | } |
1306 | |||
1307 | |||
1308 | /*++++++++++++++++++++++++++++++++++++++ | ||
1309 | The function that is called when the GPXNameType XSD type is seen | ||
1310 | |||
1311 | amb | 367 | int GPXNameType_function Returns 0 if no error occured or something else otherwise. |
1312 | amb | 363 | |
1313 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
1314 | |||
1315 | 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. |
1316 | |||
1317 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1318 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1319 | |||
1320 | amb | 373 | static int GPXNameType_function(const char *_tag_,int _type_,const char *text) |
1321 | amb | 361 | { |
1322 | if(_type_&XMLPARSE_TAG_START && store) | ||
1323 | { | ||
1324 | amb | 486 | char *xmltext; |
1325 | |||
1326 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1327 | amb | 361 | |
1328 | amb | 486 | xmltext=ParseXML_Encode_Safe_XML(text); |
1329 | amb | 1784 | loaded_translations[nloaded_translations-1]->gpx_name=strcpy(malloc(strlen(xmltext)+1),xmltext); |
1330 | amb | 361 | } |
1331 | amb | 363 | |
1332 | return(0); | ||
1333 | amb | 361 | } |
1334 | |||
1335 | |||
1336 | /*++++++++++++++++++++++++++++++++++++++ | ||
1337 | The function that is called when the GPXStepType XSD type is seen | ||
1338 | |||
1339 | amb | 367 | int GPXStepType_function Returns 0 if no error occured or something else otherwise. |
1340 | amb | 363 | |
1341 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
1342 | |||
1343 | 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. |
1344 | |||
1345 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1346 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1347 | |||
1348 | amb | 373 | static int GPXStepType_function(const char *_tag_,int _type_,const char *text) |
1349 | amb | 361 | { |
1350 | if(_type_&XMLPARSE_TAG_START && store) | ||
1351 | { | ||
1352 | amb | 486 | char *xmltext; |
1353 | |||
1354 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1355 | amb | 361 | |
1356 | amb | 486 | xmltext=ParseXML_Encode_Safe_XML(text); |
1357 | amb | 1784 | loaded_translations[nloaded_translations-1]->gpx_step=strcpy(malloc(strlen(xmltext)+1),xmltext); |
1358 | amb | 361 | } |
1359 | amb | 363 | |
1360 | return(0); | ||
1361 | amb | 361 | } |
1362 | |||
1363 | |||
1364 | /*++++++++++++++++++++++++++++++++++++++ | ||
1365 | The function that is called when the GPXFinalType XSD type is seen | ||
1366 | |||
1367 | amb | 367 | int GPXFinalType_function Returns 0 if no error occured or something else otherwise. |
1368 | amb | 363 | |
1369 | amb | 373 | const char *_tag_ Set to the name of the element tag that triggered this function call. |
1370 | |||
1371 | 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. |
1372 | |||
1373 | const char *text The contents of the 'text' attribute (or NULL if not defined). | ||
1374 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1375 | |||
1376 | amb | 373 | static int GPXFinalType_function(const char *_tag_,int _type_,const char *text) |
1377 | amb | 361 | { |
1378 | if(_type_&XMLPARSE_TAG_START && store) | ||
1379 | { | ||
1380 | amb | 486 | char *xmltext; |
1381 | |||
1382 | amb | 373 | XMLPARSE_ASSERT_STRING(_tag_,text); |
1383 | amb | 361 | |
1384 | amb | 486 | xmltext=ParseXML_Encode_Safe_XML(text); |
1385 | amb | 1784 | loaded_translations[nloaded_translations-1]->gpx_final=strcpy(malloc(strlen(xmltext)+1),xmltext); |
1386 | amb | 361 | } |
1387 | amb | 363 | |
1388 | return(0); | ||
1389 | amb | 361 | } |
1390 | |||
1391 | |||
1392 | /*++++++++++++++++++++++++++++++++++++++ | ||
1393 | The XML translation parser. | ||
1394 | |||
1395 | int ParseXMLTranslations Returns 0 if OK or something else in case of an error. | ||
1396 | |||
1397 | const char *filename The name of the file to read. | ||
1398 | |||
1399 | amb | 1791 | const char *lang The abbreviated language name to search for (NULL means first in file). |
1400 | amb | 1784 | |
1401 | int all Set to true to load all the translations. | ||
1402 | amb | 361 | ++++++++++++++++++++++++++++++++++++++*/ |
1403 | |||
1404 | amb | 1791 | int ParseXMLTranslations(const char *filename,const char *lang,int all) |
1405 | amb | 361 | { |
1406 | amb | 1186 | int fd; |
1407 | amb | 361 | int retval; |
1408 | |||
1409 | if(!ExistsFile(filename)) | ||
1410 | return(1); | ||
1411 | |||
1412 | amb | 1412 | fd=OpenFile(filename); |
1413 | amb | 361 | |
1414 | amb | 1784 | /* Delete the existing translations */ |
1415 | |||
1416 | if(nloaded_translations) | ||
1417 | FreeXMLTranslations(); | ||
1418 | |||
1419 | /* Initialise variables used for parsing */ | ||
1420 | |||
1421 | store_all=all; | ||
1422 | |||
1423 | amb | 1791 | store_lang=lang; |
1424 | amb | 1784 | |
1425 | store=0; | ||
1426 | stored=0; | ||
1427 | |||
1428 | /* Parse the file */ | ||
1429 | |||
1430 | amb | 1186 | retval=ParseXML(fd,xml_toplevel_tags,XMLPARSE_UNKNOWN_ATTR_ERRNONAME|XMLPARSE_RETURN_ATTR_ENCODED); |
1431 | amb | 361 | |
1432 | amb | 1412 | CloseFile(fd); |
1433 | amb | 361 | |
1434 | amb | 363 | if(retval) |
1435 | amb | 1784 | { |
1436 | FreeXMLTranslations(); | ||
1437 | amb | 361 | |
1438 | amb | 1784 | return(2); |
1439 | } | ||
1440 | amb | 361 | |
1441 | return(0); | ||
1442 | } | ||
1443 | amb | 1784 | |
1444 | |||
1445 | /*++++++++++++++++++++++++++++++++++++++ | ||
1446 | Return a list of the languages that have been loaded from the XML file. | ||
1447 | |||
1448 | char **GetTranslationLanguages Returns a NULL terminated list of strings - all allocated. | ||
1449 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1450 | |||
1451 | char **GetTranslationLanguages(void) | ||
1452 | { | ||
1453 | char **list=calloc(1+nloaded_translations,sizeof(char*)); | ||
1454 | int i; | ||
1455 | |||
1456 | for(i=0;i<nloaded_translations;i++) | ||
1457 | amb | 1791 | list[i]=strcpy(malloc(strlen(loaded_translations[i]->lang)+1),loaded_translations[i]->lang); |
1458 | amb | 1784 | |
1459 | return(list); | ||
1460 | } | ||
1461 | |||
1462 | |||
1463 | /*++++++++++++++++++++++++++++++++++++++ | ||
1464 | amb | 1792 | Return a list of the full names of the languages that have been loaded from the XML file. |
1465 | |||
1466 | char **GetTranslationLanguageFullNames Returns a NULL terminated list of strings - all allocated. | ||
1467 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1468 | |||
1469 | char **GetTranslationLanguageFullNames(void) | ||
1470 | { | ||
1471 | char **list=calloc(1+nloaded_translations,sizeof(char*)); | ||
1472 | int i; | ||
1473 | |||
1474 | for(i=0;i<nloaded_translations;i++) | ||
1475 | list[i]=strcpy(malloc(strlen(loaded_translations[i]->language)+1),loaded_translations[i]->language); | ||
1476 | |||
1477 | return(list); | ||
1478 | } | ||
1479 | |||
1480 | |||
1481 | /*++++++++++++++++++++++++++++++++++++++ | ||
1482 | amb | 1784 | Get a named translation. |
1483 | |||
1484 | Translation *GetTranslation Returns a pointer to the translation. | ||
1485 | |||
1486 | amb | 1791 | const char *lang The abbreviated name of the language of the translation or NULL to get the default or an empty string to get the first one. |
1487 | amb | 1784 | ++++++++++++++++++++++++++++++++++++++*/ |
1488 | |||
1489 | amb | 1791 | Translation *GetTranslation(const char *lang) |
1490 | amb | 1784 | { |
1491 | int i; | ||
1492 | |||
1493 | amb | 1791 | if(!lang) |
1494 | amb | 1784 | return(&default_translation); |
1495 | |||
1496 | amb | 1791 | if(!*lang && nloaded_translations>0) |
1497 | amb | 1784 | return(loaded_translations[0]); |
1498 | |||
1499 | for(i=0;i<nloaded_translations;i++) | ||
1500 | amb | 1791 | if(!strcmp(loaded_translations[i]->lang,lang)) |
1501 | amb | 1784 | return(loaded_translations[i]); |
1502 | |||
1503 | return(NULL); | ||
1504 | } | ||
1505 | |||
1506 | |||
1507 | /*++++++++++++++++++++++++++++++++++++++ | ||
1508 | Free the memory that has been allocated for the translations. | ||
1509 | ++++++++++++++++++++++++++++++++++++++*/ | ||
1510 | |||
1511 | void FreeXMLTranslations() | ||
1512 | { | ||
1513 | int i,j; | ||
1514 | |||
1515 | if(!loaded_translations) | ||
1516 | return; | ||
1517 | |||
1518 | for(i=0;i<nloaded_translations;i++) | ||
1519 | { | ||
1520 | amb | 1791 | free(loaded_translations[i]->lang); |
1521 | amb | 1980 | free(loaded_translations[i]->language); |
1522 | amb | 1784 | |
1523 | for(j=0;j<2;j++) | ||
1524 | { | ||
1525 | if(loaded_translations[i]->raw_copyright_creator[j] != default_translation.raw_copyright_creator[j]) free(loaded_translations[i]->raw_copyright_creator[j]); | ||
1526 | if(loaded_translations[i]->raw_copyright_source[j] != default_translation.raw_copyright_source[j]) free(loaded_translations[i]->raw_copyright_source[j]); | ||
1527 | if(loaded_translations[i]->raw_copyright_license[j] != default_translation.raw_copyright_license[j]) free(loaded_translations[i]->raw_copyright_license[j]); | ||
1528 | |||
1529 | if(loaded_translations[i]->xml_copyright_creator[j] != default_translation.xml_copyright_creator[j]) free(loaded_translations[i]->xml_copyright_creator[j]); | ||
1530 | if(loaded_translations[i]->xml_copyright_source[j] != default_translation.xml_copyright_source[j]) free(loaded_translations[i]->xml_copyright_source[j]); | ||
1531 | if(loaded_translations[i]->xml_copyright_license[j] != default_translation.xml_copyright_license[j]) free(loaded_translations[i]->xml_copyright_license[j]); | ||
1532 | } | ||
1533 | |||
1534 | for(j=0;j<9;j++) | ||
1535 | { | ||
1536 | if(loaded_translations[i]->xml_heading[j] != default_translation.xml_heading[j]) free(loaded_translations[i]->xml_heading[j]); | ||
1537 | if(loaded_translations[i]->xml_turn[j] != default_translation.xml_turn[j]) free(loaded_translations[i]->xml_turn[j]); | ||
1538 | } | ||
1539 | |||
1540 | for(j=0;j<10;j++) | ||
1541 | if(loaded_translations[i]->xml_ordinal[j] != default_translation.xml_ordinal[j]) free(loaded_translations[i]->xml_ordinal[j]); | ||
1542 | |||
1543 | for(j=0;j<9;j++) | ||
1544 | { | ||
1545 | if(loaded_translations[i]->notxml_heading[j] != default_translation.notxml_heading[j]) free(loaded_translations[i]->notxml_heading[j]); | ||
1546 | if(loaded_translations[i]->notxml_turn[j] != default_translation.notxml_turn[j]) free(loaded_translations[i]->notxml_turn[j]); | ||
1547 | } | ||
1548 | |||
1549 | for(j=0;j<10;j++) | ||
1550 | if(loaded_translations[i]->notxml_ordinal[j] != default_translation.notxml_ordinal[j]) free(loaded_translations[i]->notxml_ordinal[j]); | ||
1551 | |||
1552 | for(j=0;j<Highway_Count;j++) | ||
1553 | if(loaded_translations[i]->raw_highway[j] != default_translation.raw_highway[j]) free(loaded_translations[i]->raw_highway[j]); | ||
1554 | |||
1555 | if(loaded_translations[i]->xml_route_shortest != default_translation.xml_route_shortest) free(loaded_translations[i]->xml_route_shortest); | ||
1556 | if(loaded_translations[i]->xml_route_quickest != default_translation.xml_route_quickest) free(loaded_translations[i]->xml_route_quickest); | ||
1557 | |||
1558 | if(loaded_translations[i]->html_waypoint != default_translation.html_waypoint) free(loaded_translations[i]->html_waypoint); | ||
1559 | if(loaded_translations[i]->html_junction != default_translation.html_junction) free(loaded_translations[i]->html_junction); | ||
1560 | if(loaded_translations[i]->html_roundabout != default_translation.html_roundabout) free(loaded_translations[i]->html_roundabout); | ||
1561 | |||
1562 | if(loaded_translations[i]->html_title != default_translation.html_title) free(loaded_translations[i]->html_title); | ||
1563 | |||
1564 | if(loaded_translations[i]->html_start != default_translation.html_start) free(loaded_translations[i]->html_start); | ||
1565 | if(loaded_translations[i]->html_node != default_translation.html_node) free(loaded_translations[i]->html_node); | ||
1566 | if(loaded_translations[i]->html_rbnode != default_translation.html_rbnode) free(loaded_translations[i]->html_rbnode); | ||
1567 | if(loaded_translations[i]->html_segment != default_translation.html_segment) free(loaded_translations[i]->html_segment); | ||
1568 | if(loaded_translations[i]->html_stop != default_translation.html_stop) free(loaded_translations[i]->html_stop); | ||
1569 | if(loaded_translations[i]->html_total != default_translation.html_total) free(loaded_translations[i]->html_total); | ||
1570 | if(loaded_translations[i]->html_subtotal!= default_translation.html_subtotal)free(loaded_translations[i]->html_subtotal); | ||
1571 | |||
1572 | if(loaded_translations[i]->nothtml_waypoint != default_translation.nothtml_waypoint) free(loaded_translations[i]->nothtml_waypoint); | ||
1573 | if(loaded_translations[i]->nothtml_junction != default_translation.nothtml_junction) free(loaded_translations[i]->nothtml_junction); | ||
1574 | if(loaded_translations[i]->nothtml_roundabout != default_translation.nothtml_roundabout) free(loaded_translations[i]->nothtml_roundabout); | ||
1575 | |||
1576 | if(loaded_translations[i]->nothtml_title != default_translation.nothtml_title) free(loaded_translations[i]->nothtml_title); | ||
1577 | |||
1578 | if(loaded_translations[i]->nothtml_start != default_translation.nothtml_start) free(loaded_translations[i]->nothtml_start); | ||
1579 | if(loaded_translations[i]->nothtml_node != default_translation.nothtml_node) free(loaded_translations[i]->nothtml_node); | ||
1580 | if(loaded_translations[i]->nothtml_rbnode != default_translation.nothtml_rbnode) free(loaded_translations[i]->nothtml_rbnode); | ||
1581 | if(loaded_translations[i]->nothtml_segment != default_translation.nothtml_segment) free(loaded_translations[i]->nothtml_segment); | ||
1582 | if(loaded_translations[i]->nothtml_stop != default_translation.nothtml_stop) free(loaded_translations[i]->nothtml_stop); | ||
1583 | if(loaded_translations[i]->nothtml_total != default_translation.nothtml_total) free(loaded_translations[i]->nothtml_total); | ||
1584 | if(loaded_translations[i]->nothtml_subtotal!= default_translation.nothtml_subtotal)free(loaded_translations[i]->nothtml_subtotal); | ||
1585 | |||
1586 | if(loaded_translations[i]->gpx_desc != default_translation.gpx_desc) free(loaded_translations[i]->gpx_desc); | ||
1587 | if(loaded_translations[i]->gpx_name != default_translation.gpx_name) free(loaded_translations[i]->gpx_name); | ||
1588 | if(loaded_translations[i]->gpx_step != default_translation.gpx_step) free(loaded_translations[i]->gpx_step); | ||
1589 | if(loaded_translations[i]->gpx_final != default_translation.gpx_final) free(loaded_translations[i]->gpx_final); | ||
1590 | |||
1591 | amb | 1815 | if(loaded_translations[i]->gpx_waypt != default_translation.gpx_waypt) free(loaded_translations[i]->gpx_waypt); |
1592 | amb | 1784 | if(loaded_translations[i]->gpx_trip != default_translation.gpx_trip) free(loaded_translations[i]->gpx_trip); |
1593 | |||
1594 | free(loaded_translations[i]); | ||
1595 | } | ||
1596 | |||
1597 | free(loaded_translations); | ||
1598 | |||
1599 | loaded_translations=NULL; | ||
1600 | nloaded_translations=0; | ||
1601 | } |
Properties
Name | Value |
---|---|
cvs:description | File containing translation parsing functions. |