diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2013-05-24 20:45:46 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2013-05-24 20:45:46 +0000 |
commit | 4acd82ad52253a31987d5e1342b521f44b96b1ac (patch) | |
tree | 48e7e1e4c9bc11def9aca1ee6463dd6401d74c68 /navit | |
parent | 8dae6eced373d4b9a182ec90945675d68f5b4db2 (diff) | |
download | navit-4acd82ad52253a31987d5e1342b521f44b96b1ac.tar.gz |
Add:Core:Converted log object to new scheme
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@5506 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit')
-rw-r--r-- | navit/log.c | 23 | ||||
-rw-r--r-- | navit/vehicle.c | 14 | ||||
-rw-r--r-- | navit/xmlconfig.c | 3 | ||||
-rw-r--r-- | navit/xmlconfig.h | 4 |
4 files changed, 29 insertions, 15 deletions
diff --git a/navit/log.c b/navit/log.c index 574b7732d..60ae5c385 100644 --- a/navit/log.c +++ b/navit/log.c @@ -36,6 +36,7 @@ #include "event.h" #include "callback.h" #include "debug.h" +#include "xmlconfig.h" #include "log.h" struct log_data { @@ -45,6 +46,7 @@ struct log_data { }; struct log { + NAVIT_OBJECT FILE *f; int overwrite; int empty; @@ -63,7 +65,6 @@ struct log { struct log_data header; struct log_data data; struct log_data trailer; - struct attr **attrs; }; static void @@ -240,6 +241,8 @@ log_new(struct attr * parent,struct attr **attrs) char *filename, **wexp_data; dbg(1,"enter\n"); + ret->func=&log_func; + navit_object_ref((struct navit_object *)ret); data=attr_search(attrs, NULL, attr_data); if (! data) return NULL; @@ -347,6 +350,7 @@ log_printf(struct log *this_, char *fmt, ...) void log_destroy(struct log *this_) { + dbg(0,"enter\n"); attr_list_free(this_->attrs); callback_destroy(this_->timer_callback); event_remove_timeout(this_->timer); @@ -354,3 +358,20 @@ log_destroy(struct log *this_) log_close(this_); g_free(this_); } + +struct object_func log_func = { + attr_log, + (object_func_new)log_new, + (object_func_get_attr)navit_object_get_attr, + (object_func_iter_new)navit_object_attr_iter_new, + (object_func_iter_destroy)navit_object_attr_iter_destroy, + (object_func_set_attr)navit_object_set_attr, + (object_func_add_attr)navit_object_add_attr, + (object_func_remove_attr)navit_object_remove_attr, + (object_func_init)NULL, + (object_func_destroy)log_destroy, + (object_func_dup)NULL, + (object_func_ref)navit_object_ref, + (object_func_unref)navit_object_unref, +}; + diff --git a/navit/vehicle.c b/navit/vehicle.c index 9e9a63a8d..a67779467 100644 --- a/navit/vehicle.c +++ b/navit/vehicle.c @@ -146,15 +146,7 @@ vehicle_new(struct attr *parent, struct attr **attrs) void vehicle_destroy(struct vehicle *this_) { - /* flush all logfiles on exit to avoid loss of yet unwritten data*/ - GList *ll, *l; - gpointer key; - for(ll=l=g_hash_to_list_keys(this_->log_to_cb);l;l=g_list_next(l)) { - key=l->data; - log_write(key,"",0,log_flag_force_flush); - } - g_list_free(ll); - + dbg(0,"enter\n"); if (this_->animate_callback) { callback_destroy(this_->animate_callback); event_remove_timeout(this_->animate_timer); @@ -707,10 +699,10 @@ vehicle_add_log(struct vehicle *this_, struct log *log) } else if (!strcmp(type_attr.u.str, "binfile")) { cb=callback_new_attr_2(callback_cast(vehicle_log_binfile), attr_position_coord_geo, this_, log); } else - return 1; + return 0; g_hash_table_insert(this_->log_to_cb, log, cb); callback_list_add(this_->cbl, cb); - return 0; + return 1; } struct object_func vehicle_func = { diff --git a/navit/xmlconfig.c b/navit/xmlconfig.c index 337687895..f8a01e507 100644 --- a/navit/xmlconfig.c +++ b/navit/xmlconfig.c @@ -267,7 +267,6 @@ static struct object_func object_funcs[] = { { 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_log, NEW(log_new)}, { attr_navigation, NEW(navigation_new), GET(navigation_get_attr)}, { attr_plugins, NEW(plugins_new), NULL, NULL, NULL, NULL, NULL, NULL, INIT(plugins_init)}, { attr_plugin, NEW(plugin_new)}, @@ -289,6 +288,8 @@ object_func_lookup(enum attr_type type) return &layer_func; case attr_layout: return &layout_func; + case attr_log: + return &log_func; case attr_map: return &map_func; case attr_maps: diff --git a/navit/xmlconfig.h b/navit/xmlconfig.h index 1a2ee3691..a2b6632ca 100644 --- a/navit/xmlconfig.h +++ b/navit/xmlconfig.h @@ -54,9 +54,9 @@ struct object_func { void *(*unref)(void *); }; -extern struct object_func map_func, mapset_func, navit_func, osd_func, tracking_func, vehicle_func, maps_func, layout_func, roadprofile_func, vehicleprofile_func, layer_func, config_func, profile_option_func, script_func; +extern struct object_func map_func, mapset_func, navit_func, osd_func, tracking_func, vehicle_func, maps_func, layout_func, roadprofile_func, vehicleprofile_func, layer_func, config_func, profile_option_func, script_func, log_func; -#define HAS_OBJECT_FUNC(x) ((x) == attr_map || (x) == attr_mapset || (x) == attr_navit || (x) == attr_osd || (x) == attr_trackingo || (x) == attr_vehicle || (x) == attr_maps || (x) == attr_layout || (x) == attr_roadprofile || (x) == attr_vehicleprofile || (x) == attr_layer || (x) == attr_config || (x) == attr_profile_option || (x) == attr_script) +#define HAS_OBJECT_FUNC(x) ((x) == attr_map || (x) == attr_mapset || (x) == attr_navit || (x) == attr_osd || (x) == attr_trackingo || (x) == attr_vehicle || (x) == attr_maps || (x) == attr_layout || (x) == attr_roadprofile || (x) == attr_vehicleprofile || (x) == attr_layer || (x) == attr_config || (x) == attr_profile_option || (x) == attr_script || (x) == attr_log) #define NAVIT_OBJECT struct object_func *func; int refcount; struct attr **attrs; struct navit_object { |