navit
0.5.3-trunk
|
#include <stdlib.h>
#include <glib.h>
#include <glib/gprintf.h>
#include <string.h>
#include <ctype.h>
#include "debug.h"
#include "file.h"
#include "coord.h"
#include "item.h"
#include "xmlconfig.h"
#include "layout.h"
#include "mapset.h"
#include "projection.h"
#include "map.h"
#include "navigation.h"
#include "navit.h"
#include "plugin.h"
#include "route.h"
#include "speech.h"
#include "track.h"
#include "vehicle.h"
#include "point.h"
#include "graphics.h"
#include "gui.h"
#include "osd.h"
#include "log.h"
#include "announcement.h"
#include "vehicleprofile.h"
#include "callback.h"
#include "config_.h"
Data Structures | |
struct | xistate |
struct | xmldocument |
struct | xmlstate |
struct | attr_fixme |
struct | element_func |
struct | attr_iter |
Macros | |
#define | NEW(x) (void *(*)(struct attr *, struct attr **))(x) |
#define | GET(x) (int (*)(void *, enum attr_type type, struct attr *attr, struct attr_iter *iter))(x) |
#define | ITERN(x) (struct attr_iter * (*)(void *))(x) |
#define | ITERD(x) (void (*)(struct attr_iter *iter))(x) |
#define | SET(x) (int (*)(void *, struct attr *attr))(x) |
#define | ADD(x) (int (*)(void *, struct attr *attr))(x) |
#define | REMOVE(x) (int (*)(void *, struct attr *attr))(x) |
#define | INIT(x) (int (*)(void *))(x) |
#define | DESTROY(x) (void (*)(void *))(x) |
Functions | |
static struct attr ** | convert_to_attrs (struct xmlstate *state, struct attr_fixme *fixme) |
static const char * | find_attribute (struct xmlstate *state, const char *attribute, int required) |
static int | find_boolean (struct xmlstate *state, const char *attribute, int deflt, int required) |
static int | convert_number (const char *val) |
static int | xmlconfig_announce (struct xmlstate *state) |
struct object_func * | object_func_lookup (enum attr_type type) |
static void | initStatic (void) |
static void | start_element (xml_context *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer user_data, xmlerror **error) |
static void | end_element (xml_context *context, const gchar *element_name, gpointer user_data, xmlerror **error) |
static gboolean | parse_file (struct xmldocument *document, xmlerror **error) |
static void | xinclude (xml_context *context, const gchar **attribute_names, const gchar **attribute_values, struct xmldocument *doc_old, xmlerror **error) |
Handle xi:include XML tags. More... | |
static int | strncmp_len (const char *s1, int s1len, const char *s2) |
static int | xpointer_value (const char *test, int len, struct xistate *elem, const char **out, int out_len) |
static int | xpointer_test (const char *test, int len, struct xistate *elem) |
static int | xpointer_element_match (const char *xpointer, int len, struct xistate *elem) |
static int | xpointer_xpointer_match (const char *xpointer, int len, struct xistate *first) |
static int | xpointer_match (const char *xpointer, struct xistate *first) |
static void | xi_start_element (xml_context *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer user_data, xmlerror **error) |
static void | xi_end_element (xml_context *context, const gchar *element_name, gpointer user_data, xmlerror **error) |
static void | xi_text (xml_context *context, const gchar *text, gsize text_len, gpointer user_data, xmlerror **error) |
static void | parse_node_text (ezxml_t node, void *data, void(*start)(void *, const char *, const char **, const char **, void *, void *), void(*end)(void *, const char *, void *, void *), void(*text)(void *, const char *, int, void *, void *)) |
int | xml_parse_file (char *filename, void *data, void(*start)(xml_context *, const char *, const char **, const char **, void *, GError **), void(*end)(xml_context *, const char *, void *, GError **), void(*text)(xml_context *, const char *, gsize, void *, GError **)) |
Parses an XML file. More... | |
int | xml_parse_text (const char *document, void *data, void(*start)(xml_context *, const char *, const char **, const char **, void *, GError **), void(*end)(xml_context *, const char *, void *, GError **), void(*text)(xml_context *, const char *, gsize, void *, GError **)) |
Parses XML text. More... | |
static void | parse_node (struct xmldocument *document, ezxml_t node) |
gboolean | config_load (const char *filename, xmlerror **error) |
int | navit_object_set_methods (void *in, int in_size, void *out, int out_size) |
struct navit_object * | navit_object_new (struct attr **attrs, struct object_func *func, int size) |
struct navit_object * | navit_object_ref (struct navit_object *obj) |
void * | navit_object_unref (struct navit_object *obj) |
struct attr_iter * | navit_object_attr_iter_new (void *unused) |
void | navit_object_attr_iter_destroy (struct attr_iter *iter) |
int | navit_object_get_attr (struct navit_object *obj, enum attr_type type, struct attr *attr, struct attr_iter *iter) |
Generic get function. More... | |
void | navit_object_callbacks (struct navit_object *obj, struct attr *attr) |
int | navit_object_set_attr (struct navit_object *obj, struct attr *attr) |
int | navit_object_add_attr (struct navit_object *obj, struct attr *attr) |
int | navit_object_remove_attr (struct navit_object *obj, struct attr *attr) |
void | navit_object_destroy (struct navit_object *obj) |
Variables | |
static struct object_func | object_funcs [] |
struct element_func * | elements |
static char * | attr_fixme_itemgra [] |
static char * | attr_fixme_text [] |
static char * | attr_fixme_circle [] |
static struct attr_fixme | attr_fixmes [] |
static char * | element_fixmes [] |
#define DESTROY | ( | x | ) | (void (*)(void *))(x) |
#define GET | ( | x | ) | (int (*)(void *, enum attr_type type, struct attr *attr, struct attr_iter *iter))(x) |
#define INIT | ( | x | ) | (int (*)(void *))(x) |
#define ITERD | ( | x | ) | (void (*)(struct attr_iter *iter))(x) |
#define ITERN | ( | x | ) | (struct attr_iter * (*)(void *))(x) |
gboolean config_load | ( | const char * | filename, |
xmlerror ** | error | ||
) |
filename | FQFN of the file |
error | ptr to error details, if any |
References attr_create_hash(), attr_destroy_hash(), dbg, xmlstate::document, xmlstate::element, filename, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, xmldocument::href, initStatic(), item_create_hash(), item_destroy_hash(), lvl_debug, parse_file(), and xmldocument::user_data.
Referenced by config_load_py(), and main_real().
|
static |
val | the string value to convert |
|
static |
References attr_fixme::attr_fixme, attr_new_from_text(), xmlstate::attribute_names, xmlstate::attribute_values, dbg, attr_fixme::element, lvl_debug, lvl_error, and name.
Referenced by start_element().
|
static |
References attr::data, dbg, xmlstate::element_attr, object_func::init, lvl_info, xmlstate::object_func, xmlstate::parent, attr::u, and object_func::unref.
Referenced by xi_end_element().
|
static |
References xmlstate::attribute_names, xmlstate::attribute_values, xmlstate::element, xmlstate::error, G_MARKUP_ERROR, and G_MARKUP_ERROR_INVALID_CONTENT.
Referenced by find_boolean().
|
static |
References find_attribute(), and value.
Referenced by start_element().
|
static |
References elements, element_func::func, element_func::name, element_func::parent, element_func::type, and xmlconfig_announce().
Referenced by config_load().
int navit_object_add_attr | ( | struct navit_object * | obj, |
struct attr * | attr | ||
) |
References attr_generic_add_attr(), attr_generic_prepend_attr(), attr_to_name(), attr::callback, attr::callback_list, callback_list_add(), callback_list_call_attr_2, callback_list_new(), cbl, attr::data, dbg, lvl_debug, attr::type, and attr::u.
Referenced by config_add_attr().
void navit_object_attr_iter_destroy | ( | struct attr_iter * | iter | ) |
References attr_iter::iter.
Referenced by config_attr_iter_destroy().
struct attr_iter* navit_object_attr_iter_new | ( | void * | unused | ) |
Referenced by config_attr_iter_new().
void navit_object_callbacks | ( | struct navit_object * | obj, |
struct attr * | attr | ||
) |
References callback_list_call_attr_2, attr::data, attr::type, and attr::u.
Referenced by navigation_set_turnaround(), and navit_object_set_attr().
void navit_object_destroy | ( | struct navit_object * | obj | ) |
References attr_list_free().
Referenced by speech_destroy(), and traffic_new().
int navit_object_get_attr | ( | struct navit_object * | obj, |
enum attr_type | type, | ||
struct attr * | attr, | ||
struct attr_iter * | iter | ||
) |
Generic get function.
This function searches an attribute list for an attribute of a given type and stores it in the
parameter. Internally it calls attr_generic_get_attr(struct attr **, struct attr **, enum attr_type, struct attr *, struct attr_iter *) to retrieve the attribute; see its documentation for details.
Searching for attr_any or attr_any_xml is supported.
An iterator can be specified to get multiple attributes of the same type: The first call will return the first match; each subsequent call with the same iterator will return the next match. If no more matching attributes are found in either of them, false is returned.
obj | The object to return an attribute for. This can be any Navit object type, but the parameter should be cast to struct navit_object *
|
type | The attribute type to search for. Searching for attr_any
attr_any_xml
|
attr | Points to a struct attr
|
iter | An iterator to receive multiple attributes of the same type with subsequent calls. If NULL
|
References attr_generic_get_attr(), attr_iter::iter, and type.
Referenced by navigation_get_attr(), navit_get_attr(), and osd_get_attr().
struct navit_object* navit_object_new | ( | struct attr ** | attrs, |
struct object_func * | func, | ||
int | size | ||
) |
References attr_list_dup(), navit_object_ref(), and size.
Referenced by navigation_new(), speech_new(), and traffic_new().
struct navit_object* navit_object_ref | ( | struct navit_object * | obj | ) |
References attr_to_name(), dbg, and lvl_debug.
Referenced by layer_new(), layer_set_attr_do(), layout_new(), log_new(), map_new(), mapset_new(), navit_new(), navit_object_new(), osd_new(), profile_option_new(), roadprofile_new(), route_dup(), route_get_map_helper(), route_new(), script_new(), tracking_new(), vehicle_new(), and vehicleprofile_new().
int navit_object_remove_attr | ( | struct navit_object * | obj, |
struct attr * | attr | ||
) |
References attr_generic_remove_attr(), attr::callback, callback_list_call_attr_2, callback_list_remove(), attr::data, attr::type, and attr::u.
Referenced by config_remove_attr().
int navit_object_set_attr | ( | struct navit_object * | obj, |
struct attr * | attr | ||
) |
References attr_generic_set_attr(), attr_to_name(), dbg, lvl_debug, navit_object_callbacks(), and attr::type.
Referenced by config_set_attr(), graphics_android_new(), navigation_set_attr(), navit_set_attr_do(), and osd_set_attr().
int navit_object_set_methods | ( | void * | in, |
int | in_size, | ||
void * | out, | ||
int | out_size | ||
) |
References size.
Referenced by osd_set_methods().
void* navit_object_unref | ( | struct navit_object * | obj | ) |
References attr_to_name(), dbg, and lvl_debug.
Referenced by layer_set_attr_do().
struct object_func* object_func_lookup | ( | enum attr_type | type | ) |
References config_func, layer_func, layout_func, log_func, map_func, maps_func, mapset_func, navigation_func, navit_func, object_funcs, osd_func, profile_option_func, roadprofile_func, route_func, script_func, speech_func, tracking_func, traffic_func, type, vehicle_func, and vehicleprofile_func.
Referenced by command_call_function(), command_evaluate_single(), command_object_add_attr(), command_object_get_attr(), command_object_remove_attr(), command_register_callbacks(), command_saved_callbacks_changed(), command_set_attr(), eval_postfix(), gui_internal_menu_destroy(), gui_internal_set_refresh_callback(), and start_element().
|
static |
References xmldocument::active, xmldocument::first, xmldocument::href, xmldocument::last, parse_node(), and xmldocument::xpointer.
Referenced by config_load(), and xinclude().
|
static |
References xi_end_element(), xi_start_element(), and xi_text().
Referenced by parse_file().
|
static |
References data, and attr::text.
Referenced by xml_parse_file(), and xml_parse_text().
|
static |
context | document parse context |
element_name | the current tag name |
attribute_names | ptr to return the set of attribute names |
attribute_values | ptr return the set of attribute values |
user_data | ptr to xmlstate structure |
error | ptr return error context |
References attr_fixmes, attr_from_name(), attr::attrs, convert_to_attrs(), attr::data, dbg, element_fixmes, elements, find_boolean(), element_func::func, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, G_MARKUP_ERROR_UNKNOWN_ELEMENT, lvl_error, lvl_info, element_func::name, object_func_lookup(), element_func::parent, and attr::u.
Referenced by xi_start_element().
|
static |
References s1.
Referenced by xpointer_element_match(), xpointer_test(), and xpointer_value().
|
static |
context |
element | name |
user_data | ptr to xmldocument |
error | ptr to struct for error information |
References xmldocument::active, xistate::attribute_names, xistate::attribute_values, xistate::child, end_element(), xmldocument::first, xmldocument::last, xistate::parent, and xmldocument::user_data.
Referenced by parse_node().
|
static |
References xmldocument::active, xistate::attribute_names, xistate::attribute_values, xistate::child, xistate::element, xmldocument::first, xmldocument::last, xistate::parent, start_element(), xmldocument::user_data, xinclude(), XML_ATTR_DISTANCE, xmldocument::xpointer, and xpointer_match().
Referenced by parse_node().
|
static |
References xmldocument::active, object_func::add_attr, attr::data, xmlstate::element_attr, xmlstate::object_func, attr::str, attr::text, attr::type, attr::u, and xmldocument::user_data.
Referenced by parse_node().
|
static |
Handle xi:include XML tags.
context | The XML context in which we are parsing | |
[in] | attribute_names | An array of strings containing all XML attributes of the xi:include tag |
[in] | attribute_values | An array of strings containing all XML values (one per entry in attribute_names ) |
doc_old | The current document being parsed (before moving to the one referenced in this xi:include | |
[out] | error | A description of the error encountered if any |
References dbg, file_exists(), file_is_dir(), file_wordexp_destroy(), file_wordexp_get_array(), file_wordexp_get_count(), file_wordexp_new(), G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, xmldocument::href, xmldocument::level, lvl_debug, lvl_error, parse_file(), xmldocument::user_data, file_wordexp::we, and xmldocument::xpointer.
Referenced by xi_start_element().
int xml_parse_file | ( | char * | filename, |
void * | data, | ||
void(*)(xml_context *, const char *, const char **, const char **, void *, GError **) | start, | ||
void(*)(xml_context *, const char *, void *, GError **) | end, | ||
void(*)(xml_context *, const char *, gsize, void *, GError **) | text | ||
) |
Parses an XML file.
filename | The XML file to parse |
data | Points to a user-defined data structure which will be passed to each of the callbacks passed in the following arguments |
start | Callback which will be called when an open tag is encountered |
end | Callback which will be called when a close tag is encountered |
text | Callback which will be called when character data is encountered |
References data, dbg, filename, lvl_debug, lvl_error, parse_node_text(), attr::text, and xml_parse_text().
Referenced by traffic_get_messages_from_xml_file().
int xml_parse_text | ( | const char * | document, |
void * | data, | ||
void(*)(xml_context *, const char *, const char **, const char **, void *, GError **) | start, | ||
void(*)(xml_context *, const char *, void *, GError **) | end, | ||
void(*)(xml_context *, const char *, gsize, void *, GError **) | text | ||
) |
Parses XML text.
document | The XML data to parse |
data | Points to a user-defined data structure which will be passed to each of the callbacks passed in the following arguments |
start | Callback which will be called when an open tag is encountered |
end | Callback which will be called when a close tag is encountered |
text | Callback which will be called when character data is encountered |
References context, data, dbg, lvl_error, parse_node_text(), attr::str, and attr::text.
Referenced by gui_internal_html_parse_text(), traffic_get_messages_from_xml_string(), and xml_parse_file().
|
static |
Referenced by initStatic().
|
static |
References xistate::element, strncmp_len(), and xpointer_test().
Referenced by xpointer_xpointer_match().
|
static |
References xpointer_xpointer_match().
Referenced by xi_start_element().
|
static |
References c, strncmp_len(), and xpointer_value().
Referenced by xpointer_element_match().
|
static |
References xistate::attribute_names, xistate::attribute_values, xistate::element, and strncmp_len().
Referenced by xpointer_test().
|
static |
References c, xistate::child, dbg, lvl_info, and xpointer_element_match().
Referenced by xpointer_match().
|
static |
|
static |
|
static |
|
static |
Referenced by start_element().
|
static |
Referenced by start_element().
struct element_func* elements |
Referenced by compare_name_systematic(), initStatic(), and start_element().
|
static |
Referenced by object_func_lookup().