/[zanavi_public1]/navit/navit/xmlconfig.c
ZANavi

Diff of /navit/navit/xmlconfig.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 30 Revision 31
264#define ADD(x) (int (*)(void *, struct attr *attr))(x) 264#define ADD(x) (int (*)(void *, struct attr *attr))(x)
265#define REMOVE(x) (int (*)(void *, struct attr *attr))(x) 265#define REMOVE(x) (int (*)(void *, struct attr *attr))(x)
266#define INIT(x) (int (*)(void *))(x) 266#define INIT(x) (int (*)(void *))(x)
267#define DESTROY(x) (void (*)(void *))(x) 267#define DESTROY(x) (void (*)(void *))(x)
268 268
269static struct object_func object_funcs[] = 269static struct object_func
270{ 270 object_funcs[] =
271{ attr_announcement, NEW(announcement_new), GET(announcement_get_attr), NULL, NULL, SET(announcement_set_attr), ADD(announcement_add_attr) }, 271 { { attr_announcement, NEW(announcement_new), GET(announcement_get_attr), NULL, NULL, SET(announcement_set_attr), ADD(announcement_add_attr) }, { attr_arrows, NEW(arrows_new) }, { attr_circle, NEW(circle_new), NULL, NULL, NULL, NULL, ADD(element_add_attr) }, { attr_config, NEW(config_new), GET(config_get_attr), ITERN(config_attr_iter_new), ITERD(config_attr_iter_destroy), SET(config_set_attr), ADD(config_add_attr), REMOVE(config_remove_attr), NULL, DESTROY(config_destroy) }, { attr_coord, NEW(coord_new_from_attrs) }, { attr_cursor, NEW(cursor_new), NULL, NULL, NULL, NULL, ADD(cursor_add_attr) }, { attr_debug, NEW(debug_new) }, { attr_graphics, NEW(graphics_new) }, { attr_gui, NEW(gui_new), GET(gui_get_attr), NULL, NULL, SET(gui_set_attr), ADD(gui_add_attr) }, { attr_icon, NEW(icon_new), NULL, NULL, NULL, NULL, ADD(element_add_attr) }, { attr_image, NEW(image_new) }, { attr_itemgra, NEW(itemgra_new), NULL, NULL, NULL, NULL, ADD(itemgra_add_attr) }, { attr_layer, NEW(layer_new), NULL, NULL, NULL, NULL, ADD(layer_add_attr) }, { attr_layout, NEW(layout_new), NULL, NULL, NULL, NULL, ADD(layout_add_attr) }, { attr_log, NEW(log_new) }, { attr_map, NEW(map_new) }, { attr_mapset, NEW(mapset_new), NULL, NULL, NULL, NULL, ADD(mapset_add_attr_name) }, { attr_navigation, NEW(navigation_new), GET(navigation_get_attr) }, { attr_navit, NEW(navit_new), GET(navit_get_attr), ITERN(navit_attr_iter_new), ITERD(navit_attr_iter_destroy), SET(navit_set_attr), ADD(navit_add_attr), REMOVE(navit_remove_attr), INIT(navit_init), DESTROY(navit_destroy) }, { attr_osd, NEW(osd_new) }, { attr_plugins, NEW(plugins_new), NULL, NULL, NULL, NULL, NULL, NULL, INIT(plugins_init) }, { attr_plugin, NEW(plugin_new) }, { attr_polygon, NEW(polygon_new), NULL, NULL, NULL, NULL, ADD(element_add_attr) }, { attr_polyline, NEW(polyline_new), NULL, NULL, NULL, NULL, ADD(element_add_attr) }, { attr_roadprofile, NEW(roadprofile_new), GET(roadprofile_get_attr), NULL, NULL, SET(roadprofile_set_attr), ADD(roadprofile_add_attr) }, { attr_route, NEW(route_new), GET(route_get_attr), NULL, NULL, SET(route_set_attr), ADD(route_add_attr), REMOVE(route_remove_attr) }, { attr_speech, NEW(speech_new), GET(speech_get_attr), NULL, NULL, SET(speech_set_attr) }, { attr_text, NEW(text_new) }, { attr_tracking, NEW(tracking_new) }, { attr_vehicle, NEW(vehicle_new), GET(vehicle_get_attr), NULL, NULL, SET(vehicle_set_attr), ADD(vehicle_add_attr), REMOVE(vehicle_remove_attr) }, { attr_vehicleprofile, NEW(vehicleprofile_new), GET(vehicleprofile_get_attr), NULL, NULL, SET(vehicleprofile_set_attr), ADD(vehicleprofile_add_attr) }, };
272{ attr_arrows, NEW(arrows_new) },
273{ attr_circle, NEW(circle_new), NULL, NULL, NULL, NULL, ADD(element_add_attr) },
274{ attr_config, NEW(config_new), GET(config_get_attr), ITERN(config_attr_iter_new), ITERD(config_attr_iter_destroy), SET(config_set_attr), ADD(config_add_attr), REMOVE(config_remove_attr), NULL, DESTROY(config_destroy) },
275{ attr_coord, NEW(coord_new_from_attrs) },
276{ attr_cursor, NEW(cursor_new), NULL, NULL, NULL, NULL, ADD(cursor_add_attr) },
277{ attr_debug, NEW(debug_new) },
278{ attr_graphics, NEW(graphics_new) },
279{ attr_gui, NEW(gui_new), GET(gui_get_attr), NULL, NULL, SET(gui_set_attr), ADD(gui_add_attr) },
280{ attr_icon, NEW(icon_new), NULL, NULL, NULL, NULL, ADD(element_add_attr) },
281{ attr_image, NEW(image_new) },
282{ attr_itemgra, NEW(itemgra_new), NULL, NULL, NULL, NULL, ADD(itemgra_add_attr) },
283{ attr_layer, NEW(layer_new), NULL, NULL, NULL, NULL, ADD(layer_add_attr) },
284{ attr_layout, NEW(layout_new), NULL, NULL, NULL, NULL, ADD(layout_add_attr) },
285{ attr_log, NEW(log_new) },
286{ attr_map, NEW(map_new) },
287{ attr_mapset, NEW(mapset_new), NULL, NULL, NULL, NULL, ADD(mapset_add_attr_name) },
288{ attr_navigation, NEW(navigation_new), GET(navigation_get_attr) },
289{ attr_navit, NEW(navit_new), GET(navit_get_attr), ITERN(navit_attr_iter_new), ITERD(navit_attr_iter_destroy), SET(navit_set_attr), ADD(navit_add_attr), REMOVE(navit_remove_attr), INIT(navit_init), DESTROY(navit_destroy) },
290{ attr_osd, NEW(osd_new) },
291{ attr_plugins, NEW(plugins_new), NULL, NULL, NULL, NULL, NULL, NULL, INIT(plugins_init) },
292{ attr_plugin, NEW(plugin_new) },
293{ attr_polygon, NEW(polygon_new), NULL, NULL, NULL, NULL, ADD(element_add_attr) },
294{ attr_polyline, NEW(polyline_new), NULL, NULL, NULL, NULL, ADD(element_add_attr) },
295{ attr_roadprofile, NEW(roadprofile_new), GET(roadprofile_get_attr), NULL, NULL, SET(roadprofile_set_attr), ADD(roadprofile_add_attr) },
296{ attr_route, NEW(route_new), GET(route_get_attr), NULL, NULL, SET(route_set_attr), ADD(route_add_attr), REMOVE(route_remove_attr) },
297{ attr_speech, NEW(speech_new), GET(speech_get_attr), NULL, NULL, SET(speech_set_attr) },
298{ attr_text, NEW(text_new) },
299{ attr_tracking, NEW(tracking_new) },
300{ attr_vehicle, NEW(vehicle_new), GET(vehicle_get_attr), NULL, NULL, SET(vehicle_set_attr), ADD(vehicle_add_attr), REMOVE(vehicle_remove_attr) },
301{ attr_vehicleprofile, NEW(vehicleprofile_new), GET(vehicleprofile_get_attr), NULL, NULL, SET(vehicleprofile_set_attr), ADD(vehicleprofile_add_attr) }, };
302 272
303struct object_func * 273struct object_func *
304object_func_lookup(enum attr_type type) 274object_func_lookup(enum attr_type type)
305{ 275{
306 int i; 276 int i;
319 int (*func)(struct xmlstate *state); 289 int (*func)(struct xmlstate *state);
320 enum attr_type type; 290 enum attr_type type;
321}; 291};
322struct element_func *elements; 292struct element_func *elements;
323 293
324static char *attr_fixme_itemgra[] = 294static char *attr_fixme_itemgra[] = { "type", "item_types", NULL, NULL, };
325{ "type", "item_types", NULL, NULL, };
326 295
327static char *attr_fixme_text[] = 296static char *attr_fixme_text[] = { "label_size", "text_size", NULL, NULL, };
328{ "label_size", "text_size", NULL, NULL, };
329 297
330static char *attr_fixme_circle[] = 298static char *attr_fixme_circle[] = { "label_size", "text_size", NULL, NULL, };
331{ "label_size", "text_size", NULL, NULL, };
332 299
333static struct attr_fixme attr_fixmes[] = 300static struct attr_fixme attr_fixmes[] = { { "item", attr_fixme_itemgra }, { "itemgra", attr_fixme_itemgra }, { "text", attr_fixme_text }, { "label", attr_fixme_text }, { "circle", attr_fixme_circle }, { NULL, NULL }, };
334{
335{ "item", attr_fixme_itemgra },
336{ "itemgra", attr_fixme_itemgra },
337{ "text", attr_fixme_text },
338{ "label", attr_fixme_text },
339{ "circle", attr_fixme_circle },
340{ NULL, NULL }, };
341 301
342static char *element_fixmes[] =
343{ "item", "itemgra", "label", "text", NULL, NULL, }; 302static char *element_fixmes[] = { "item", "itemgra", "label", "text", NULL, NULL, };
344 303
345static void initStatic(void) 304static void initStatic(void)
346{ 305{
347 elements=g_new0(struct element_func,40); //39 is a number of elements + ending NULL element 306 elements=g_new0(struct element_func,40); //39 is a number of elements + ending NULL element
348 307
611 g_free(possible_parents); 570 g_free(possible_parents);
612 return; 571 return;
613 } 572 }
614 if (!func) 573 if (!func)
615 { 574 {
616 g_set_error(error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "Element '%s' within unexpected context '%s'. Expected '%s'%s", element_name, parent_name, possible_parents, 575 g_set_error(error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "Element '%s' within unexpected context '%s'. Expected '%s'%s", element_name, parent_name, possible_parents, !strcmp(possible_parents, "config") ? "\nPlease add <config> </config> tags at the beginning/end of your navit.xml" : "");
617 !strcmp(possible_parents, "config") ? "\nPlease add <config> </config> tags at the beginning/end of your navit.xml" : "");
618 g_free(possible_parents); 576 g_free(possible_parents);
619 return; 577 return;
620 } 578 }
621 g_free(possible_parents); 579 g_free(possible_parents);
622 580
1202 xi_end_element(NULL, node->name, document, NULL); 1160 xi_end_element(NULL, node->name, document, NULL);
1203 node = node->ordered; 1161 node = node->ordered;
1204 } 1162 }
1205} 1163}
1206 1164
1207
1208
1209
1210
1211// this is used on android!!!! 1165// this is used on android!!!!
1212// this is used on android!!!! 1166// this is used on android!!!!
1213// this is used on android!!!! 1167// this is used on android!!!!
1214// this is used on android!!!! 1168// this is used on android!!!!
1215static gboolean parse_file(struct xmldocument *document, xmlerror **error) 1169static gboolean parse_file(struct xmldocument *document, xmlerror **error)
1255 dbg(0, "XML-----XML-----enter filename='%s'\n", filename); 1209 dbg(0, "XML-----XML-----enter filename='%s'\n", filename);
1256 memset(&document, 0, sizeof(document)); 1210 memset(&document, 0, sizeof(document));
1257 document.href = filename; 1211 document.href = filename;
1258 document.user_data = &curr; 1212 document.user_data = &curr;
1259 result = parse_file(&document, error); 1213 result = parse_file(&document, error);
1214 //dbg(0,"xml 003\n");
1260 if (result && curr) 1215 if (result && curr)
1261 { 1216 {
1262 g_set_error(error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, "element '%s' not closed", curr->element); 1217 g_set_error(error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, "element '%s' not closed", curr->element);
1263 result = FALSE; 1218 result = FALSE;
1264 } 1219 }

Legend:
Removed from v.30  
changed lines
  Added in v.31

   
Visit the ZANavi Wiki