diff options
author | Stefan Wildemann <metalstrolch@users.noreply.github.com> | 2019-10-30 02:03:04 +0100 |
---|---|---|
committer | Pierre GRANDIN <pgrandin@users.noreply.github.com> | 2019-10-29 19:03:04 -0600 |
commit | 10f514af97b3491072a172b3e0f3e78de455bfb3 (patch) | |
tree | f69b02446ffd41ea8eb37e65e6d5def590bb963d | |
parent | c62df58958a3a086521b9a6796c6c793f4f68d57 (diff) | |
download | navit-10f514af97b3491072a172b3e0f3e78de455bfb3.tar.gz |
fix:all:fix compiler warnings (#935)
* fix:core:remove many compiler warnings from core
-rw-r--r-- | navit/attr.c | 4 | ||||
-rw-r--r-- | navit/attr.h | 1 | ||||
-rw-r--r-- | navit/binding/dbus/binding_dbus.c | 8 | ||||
-rw-r--r-- | navit/bookmarks.c | 19 | ||||
-rw-r--r-- | navit/config_.c | 4 | ||||
-rw-r--r-- | navit/config_.h | 2 | ||||
-rw-r--r-- | navit/coord.c | 4 | ||||
-rw-r--r-- | navit/debug.c | 4 | ||||
-rw-r--r-- | navit/file.c | 4 | ||||
-rw-r--r-- | navit/gui/gtk/gui_gtk_action.c | 4 | ||||
-rw-r--r-- | navit/gui/gtk/gui_gtk_window.c | 6 | ||||
-rw-r--r-- | navit/gui/internal/gui_internal_command.c | 8 | ||||
-rw-r--r-- | navit/gui/qt5_qml/backend.cpp | 6 | ||||
-rw-r--r-- | navit/layout.c | 3 | ||||
-rw-r--r-- | navit/layout.h | 2 | ||||
-rw-r--r-- | navit/log.c | 7 | ||||
-rw-r--r-- | navit/main.c | 7 | ||||
-rw-r--r-- | navit/mapset.c | 2 | ||||
-rw-r--r-- | navit/mapset.h | 2 | ||||
-rw-r--r-- | navit/maptool/maptool.c | 2 | ||||
-rw-r--r-- | navit/navigation.c | 7 | ||||
-rw-r--r-- | navit/navit.c | 185 | ||||
-rw-r--r-- | navit/navit.h | 4 | ||||
-rw-r--r-- | navit/plugin.c | 5 | ||||
-rw-r--r-- | navit/plugin.h | 48 | ||||
-rw-r--r-- | navit/popup.c | 4 | ||||
-rw-r--r-- | navit/route.c | 7 | ||||
-rw-r--r-- | navit/traffic.c | 4 | ||||
-rw-r--r-- | navit/xmlconfig.c | 5 | ||||
-rw-r--r-- | navit/xmlconfig.h | 46 |
30 files changed, 228 insertions, 186 deletions
diff --git a/navit/attr.c b/navit/attr.c index 58cfe621d..7eff92fb8 100644 --- a/navit/attr.c +++ b/navit/attr.c @@ -836,6 +836,10 @@ void attr_free(struct attr *attr) { g_free(attr); } +void attr_free_g(struct attr *attr, void * unused) { + attr_free(attr); +} + void attr_dup_content(struct attr *src, struct attr *dst) { int size; dst->type=src->type; diff --git a/navit/attr.h b/navit/attr.h index ab4283394..d4cd07a1e 100644 --- a/navit/attr.h +++ b/navit/attr.h @@ -238,6 +238,7 @@ void attr_data_set(struct attr *attr, void *data); void attr_data_set_le(struct attr *attr, void *data); void attr_free_content(struct attr *attr); void attr_free(struct attr *attr); +void attr_free_g(struct attr *attr, void * unused); /* to use as GFunc in glib context */ void attr_dup_content(struct attr *src, struct attr *dst); struct attr *attr_dup(struct attr *attr); void attr_list_free(struct attr **attrs); diff --git a/navit/binding/dbus/binding_dbus.c b/navit/binding/dbus/binding_dbus.c index 5eddc50f7..84ed7fe00 100644 --- a/navit/binding/dbus/binding_dbus.c +++ b/navit/binding/dbus/binding_dbus.c @@ -1167,7 +1167,7 @@ static DBusHandlerResult request_navit_set_layout(DBusConnection *connection, DB if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &new_layout_name, DBUS_TYPE_INVALID)) return dbus_error_invalid_parameter(connection, message); - iter=navit_attr_iter_new(); + iter=navit_attr_iter_new(NULL); while(navit_get_attr(navit, attr_layout, &attr, iter)) { if (strcmp(attr.u.layout->name, new_layout_name) == 0) { navit_set_attr(navit, &attr); @@ -1241,7 +1241,7 @@ static DBusHandlerResult request_navit_traffic_export_gpx(DBusConnection *connec dbus_message_iter_get_basic(&iter, &filename); - a_iter = navit_attr_iter_new(); + a_iter = navit_attr_iter_new(NULL); if (navit_get_attr(navit, attr_traffic, &attr, a_iter)) traffic = (struct traffic *) attr.u.navit_object; navit_attr_iter_destroy(a_iter); @@ -1357,7 +1357,7 @@ static DBusHandlerResult request_navit_traffic_inject(DBusConnection *connection dbus_message_iter_get_basic(&iter, &filename); attr = g_new0(struct attr, 1); - a_iter = navit_attr_iter_new(); + a_iter = navit_attr_iter_new(NULL); if (navit_get_attr(navit, attr_traffic, attr, a_iter)) traffic = (struct traffic *) attr->u.navit_object; navit_attr_iter_destroy(a_iter); @@ -1648,7 +1648,7 @@ static DBusHandlerResult request_navit_get_attr(DBusConnection *connection, DBus static DBusHandlerResult request_navit_attr_iter(DBusConnection *connection, DBusMessage *message) { DBusMessage *reply; - struct attr_iter *attr_iter=navit_attr_iter_new(); + struct attr_iter *attr_iter=navit_attr_iter_new(NULL); char *opath=object_new("navit_attr_iter",attr_iter); reply = dbus_message_new_method_return(message); dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &opath, DBUS_TYPE_INVALID); diff --git a/navit/bookmarks.c b/navit/bookmarks.c index f32b6d89c..9877a6dba 100644 --- a/navit/bookmarks.c +++ b/navit/bookmarks.c @@ -364,7 +364,7 @@ static int bookmarks_store_bookmarks_to_file(struct bookmarks *this_, int limit #ifdef FlushFileBuffers FlushFileBuffers(f) -#endif FlushFileBuffers +#endif fclose(f); @@ -378,7 +378,7 @@ static int bookmarks_store_bookmarks_to_file(struct bookmarks *this_, int limit unlink(this_->bookmark_file); #ifdef _POSIX sync(); -#endif _POSIX +#endif result=(rename(this_->working_file,this_->bookmark_file)==0); if (!result) { navit_add_message(this_->parent->u.navit,_("Failed to write bookmarks file")); @@ -421,7 +421,8 @@ void bookmarks_set_center_from_file(struct bookmarks *this_, char *file) { f = fopen(file, "r"); if (! f) return; - getline(&line, &line_size, f); + if(getline(&line, &line_size, f) < 0) + dbg(lvl_error, "Error on getline (%s)", strerror(errno)); fclose(f); if (line) { center = transform_center(this_->trans); @@ -631,9 +632,15 @@ struct former_destination { GList* c; }; -static void free_former_destination(struct former_destination* former_destination) { +/* to adapt g_free to GFunc */ +static void g_free_helper(void * data, void*user_data) { + g_free(data); +} + +/* unused parameter is for GFunc compatibility */ +static void free_former_destination(struct former_destination* former_destination, void * unused) { g_free(former_destination->description); - g_list_foreach(former_destination->c, (GFunc)g_free, NULL); + g_list_foreach(former_destination->c, (GFunc)g_free_helper, NULL); g_list_free(former_destination->c); g_free(former_destination); } @@ -693,7 +700,7 @@ static GList* find_destination_in_list(struct former_destination* dest_to_remove curr_dest = curr_el->data; if (destination_equal(dest_to_remove, curr_dest, remove_found?0:1)) { if(remove_found) { - free_former_destination(curr_dest); + free_former_destination(curr_dest, NULL); curr_el = g_list_remove(curr_el, curr_dest); continue; } else { diff --git a/navit/config_.c b/navit/config_.c index 644b66d70..2149eaf2e 100644 --- a/navit/config_.c +++ b/navit/config_.c @@ -109,8 +109,8 @@ int config_remove_attr(struct config *this_, struct attr *attr) { } struct attr_iter * -config_attr_iter_new() { - return navit_object_attr_iter_new(); +config_attr_iter_new(void * unused) { + return navit_object_attr_iter_new(unused); } void config_attr_iter_destroy(struct attr_iter *iter) { diff --git a/navit/config_.h b/navit/config_.h index 64ac0465c..78710dcbb 100644 --- a/navit/config_.h +++ b/navit/config_.h @@ -17,7 +17,7 @@ int config_get_attr(struct config *this_, enum attr_type type, struct attr *attr int config_set_attr(struct config *this_, struct attr *attr); int config_add_attr(struct config *this_, struct attr *attr); int config_remove_attr(struct config *this_, struct attr *attr); -struct attr_iter *config_attr_iter_new(void); +struct attr_iter *config_attr_iter_new(void * unused); void config_attr_iter_destroy(struct attr_iter *iter); struct config *config_new(struct attr *parent, struct attr **attrs); /* end of prototypes */ diff --git a/navit/coord.c b/navit/coord.c index c452f1c35..cc64044bd 100644 --- a/navit/coord.c +++ b/navit/coord.c @@ -378,6 +378,10 @@ void coord_format_with_sep(float lat,float lng, enum coord_format fmt, char *buf size_used+=g_snprintf(buffer+size_used,size-size_used,"%.0f°%.0f'%.0f\"%c",floor(lng_deg),floor(lng_min), round(lng_sec),lng_c); break; + /* compiler warned about those not being handled. What to do with them?*/ + case DEGREES_DECIMAL_ABSOLUTE: + case DEGREES_DECIMAL: + break; } } diff --git a/navit/debug.c b/navit/debug.c index ef485ad8a..6321756b6 100644 --- a/navit/debug.c +++ b/navit/debug.c @@ -74,11 +74,13 @@ static void sigsegv(int sig) { #include <unistd.h> static void sigsegv(int sig) { char buffer[256]; + int retval; if (segv_level > 1) sprintf(buffer, "gdb -ex bt %s %d", gdb_program, getpid()); else sprintf(buffer, "gdb -ex bt -ex detach -ex quit %s %d", gdb_program, getpid()); - system(buffer); + retval = system(buffer); + fprintf(stderr, "calling gdb returned %d\n", retval); exit(1); } #endif diff --git a/navit/file.c b/navit/file.c index 8d0365499..680b355b2 100644 --- a/navit/file.c +++ b/navit/file.c @@ -99,8 +99,8 @@ static void file_http_request(struct file *file, char *method, char *host, char char *request=g_strdup_printf("%s %s HTTP/1.0\r\nUser-Agent: navit %s\r\nHost: %s\r\n%s%s%s\r\n",method,path, NAVIT_VERSION, host,persistent?"Connection: Keep-Alive\r\n":"",header?header:"",header?"\r\n":""); - write(file->fd, request, strlen(request)); - dbg(lvl_debug,"%s",request); + int retval = write(file->fd, request, strlen(request)); + dbg(lvl_debug,"%s returned %d",request, retval); file->requests++; } diff --git a/navit/gui/gtk/gui_gtk_action.c b/navit/gui/gtk/gui_gtk_action.c index ca5ff9427..7b700c7d5 100644 --- a/navit/gui/gtk/gui_gtk_action.c +++ b/navit/gui/gtk/gui_gtk_action.c @@ -158,6 +158,7 @@ static void info_action(GtkWidget *w, struct gui_priv *gui, void *dummy) { struct coord lt, rb; struct point p; struct transformation *t; + int retval; t=navit_get_trans(gui->nav); transform_get_size(t, &mw, &mh); @@ -169,7 +170,8 @@ static void info_action(GtkWidget *w, struct gui_priv *gui, void *dummy) { transform_reverse(t, &p, &rb); sprintf(buffer,"./info.sh %d,%d 0x%x,0x%x 0x%x,0x%x", mw, mh, lt.x, lt.y, rb.x, rb.y); - system(buffer); + retval=system(buffer); + dbg(lvl_debug,"calling %s returned %d", buffer, retval); } diff --git a/navit/gui/gtk/gui_gtk_window.c b/navit/gui/gtk/gui_gtk_window.c index 858904ddb..008659c44 100644 --- a/navit/gui/gtk/gui_gtk_window.c +++ b/navit/gui/gtk/gui_gtk_window.c @@ -413,7 +413,7 @@ static void gui_gtk_layouts_init(struct gui_priv *this) { int count=0; char *name; - iter=navit_attr_iter_new(); + iter=navit_attr_iter_new(NULL); while(navit_get_attr(this->nav, attr_layout, &attr, iter)) { name=g_strdup_printf("Layout %d", count++); data=g_new(struct action_cb_data, 1); @@ -466,7 +466,7 @@ static void gui_gtk_vehicles_update(struct gui_priv *this) { g_list_free(this->vehicle_menuitems); this->vehicle_menuitems = NULL; - iter=navit_attr_iter_new(); + iter=navit_attr_iter_new(NULL); while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) { vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL); name=g_strdup_printf("Vehicle %d", count++); @@ -495,7 +495,7 @@ static void gui_gtk_maps_init(struct gui_priv *this) { int count=0; char *name, *label; - iter=navit_attr_iter_new(); + iter=navit_attr_iter_new(NULL); while(navit_get_attr(this->nav, attr_map, &attr, iter)) { name=g_strdup_printf("Map %d", count++); if (! map_get_attr(attr.u.map, attr_type, &type, NULL)) diff --git a/navit/gui/internal/gui_internal_command.c b/navit/gui/internal/gui_internal_command.c index 910e2e8cf..ffd795b7d 100644 --- a/navit/gui/internal/gui_internal_command.c +++ b/navit/gui/internal/gui_internal_command.c @@ -200,7 +200,7 @@ static void gui_internal_cmd2_setting_vehicle(struct gui_priv *this, char *funct struct attr_iter *iter; struct attr active_vehicle; - iter=navit_attr_iter_new(); + iter=navit_attr_iter_new(NULL); if (navit_get_attr(this->nav, attr_vehicle, &attr, iter) && !navit_get_attr(this->nav, attr_vehicle, &attr2, iter)) { vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL); navit_attr_iter_destroy(iter); @@ -215,7 +215,7 @@ static void gui_internal_cmd2_setting_vehicle(struct gui_priv *this, char *funct gui_internal_widget_append(wb, w); if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL)) active_vehicle.u.vehicle=NULL; - iter=navit_attr_iter_new(); + iter=navit_attr_iter_new(NULL); while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) { vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL); wl=gui_internal_button_new_with_callback(this, vattr.u.str, @@ -278,7 +278,7 @@ static void gui_internal_cmd2_setting_maps(struct gui_priv *this, char *function //w->spy=this->spacing*3; w = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1); gui_internal_widget_append(wb, w); - iter=navit_attr_iter_new(); + iter=navit_attr_iter_new(NULL); on.type=off.type=attr_active; on.u.num=1; off.u.num=0; @@ -323,7 +323,7 @@ static void gui_internal_cmd2_setting_layout(struct gui_priv *this, char *functi wb=gui_internal_menu(this, _("Layout")); w=gui_internal_widget_table_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill,1); gui_internal_widget_append(wb, w); - iter=navit_attr_iter_new(); + iter=navit_attr_iter_new(NULL); while(navit_get_attr(this->nav, attr_layout, &attr, iter)) { gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this, gravity_left|orientation_horizontal|flags_fill)); diff --git a/navit/gui/qt5_qml/backend.cpp b/navit/gui/qt5_qml/backend.cpp index 7a455c2a6..c9733b173 100644 --- a/navit/gui/qt5_qml/backend.cpp +++ b/navit/gui/qt5_qml/backend.cpp @@ -69,7 +69,7 @@ void Backend::get_maps() { struct attr_iter * iter; _maps.clear(); - iter = navit_attr_iter_new(); + iter = navit_attr_iter_new(NULL); on.type = off.type = attr_active; on.u.num = 1; off.u.num = 0; @@ -106,7 +106,7 @@ void Backend::get_vehicles() { struct attr active_vehicle; _vehicles.clear(); - iter=navit_attr_iter_new(); + iter=navit_attr_iter_new(NULL); if (navit_get_attr(this->nav, attr_vehicle, &attr, iter) && !navit_get_attr(this->nav, attr_vehicle, &attr2, iter)) { vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL); navit_attr_iter_destroy(iter); @@ -119,7 +119,7 @@ void Backend::get_vehicles() { if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL)) active_vehicle.u.vehicle=NULL; - iter=navit_attr_iter_new(); + iter=navit_attr_iter_new(NULL); while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) { vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL); dbg(lvl_debug, "adding vehicle %s", vattr.u.str); diff --git a/navit/layout.c b/navit/layout.c index 65e4b7265..7ecea6c27 100644 --- a/navit/layout.c +++ b/navit/layout.c @@ -98,7 +98,7 @@ struct attr_iter { struct attr_iter * -layout_attr_iter_new(void) { +layout_attr_iter_new(void* unused) { return g_new0(struct attr_iter, 1); } @@ -282,6 +282,7 @@ static int layer_set_attr_do(struct layer *l, struct attr *attr, int init) { dbg(lvl_error, "Ignoring reference to unknown layer '%s' in layer '%s'.", attr->u.str, l->name); } obj->func->iter_destroy(iter); + return 0; default: return 0; } diff --git a/navit/layout.h b/navit/layout.h index 8b8a63194..7f19460e2 100644 --- a/navit/layout.h +++ b/navit/layout.h @@ -135,7 +135,7 @@ struct polygon; struct polyline; struct text; struct layout *layout_new(struct attr *parent, struct attr **attrs); -struct attr_iter *layout_attr_iter_new(void); +struct attr_iter *layout_attr_iter_new(void* unused); void layout_attr_iter_destroy(struct attr_iter *iter); int layout_get_attr(struct layout *layout, enum attr_type type, struct attr *attr, struct attr_iter *iter); int layout_add_attr(struct layout *layout, struct attr *attr); diff --git a/navit/log.c b/navit/log.c index 3c40e9152..d68312938 100644 --- a/navit/log.c +++ b/navit/log.c @@ -47,7 +47,9 @@ #include "debug.h" #include "xmlconfig.h" #include "log.h" - +#ifndef HAVE_API_WIN32_BASE +#include <errno.h> +#endif struct log_data { int len; int max_len; @@ -239,7 +241,8 @@ static void log_flush(struct log *this_, enum log_flags flags) { #ifndef HAVE_API_WIN32_BASE if (flags & log_flag_truncate) { pos=ftell(this_->f); - ftruncate(fileno(this_->f), pos); + if(ftruncate(fileno(this_->f), pos) <0) + dbg(lvl_error,"Error on fruncate (%s)", strerror(errno)); } #endif if (this_->trailer.len) { diff --git a/navit/main.c b/navit/main.c index 898fb9dca..84ec577aa 100644 --- a/navit/main.c +++ b/navit/main.c @@ -358,7 +358,12 @@ void main_init(const char *program) { if (file_exists("navit.c") || file_exists("navit.o") || file_exists("navit.lo") || file_exists("version.h")) { char buffer[PATH_MAX]; printf("%s",_("Running from source directory\n")); - getcwd(buffer, PATH_MAX); /* libc of navit returns "dummy" */ + if(getcwd(buffer, PATH_MAX)==NULL) { /*libc of navit returns "dummy" */ + printf("%s",_("Error getting current path. use ./ \n")); + buffer[0]='.'; + buffer[1]='/'; + buffer[2]=0; + } setenv("NAVIT_PREFIX", buffer, 0); main_setup_environment(0); } else { diff --git a/navit/mapset.c b/navit/mapset.c index 58751ee1e..94f1f42be 100644 --- a/navit/mapset.c +++ b/navit/mapset.c @@ -74,7 +74,7 @@ struct mapset *mapset_dup(struct mapset *ms) { struct attr_iter * -mapset_attr_iter_new(void) { +mapset_attr_iter_new(void* unused) { return g_new0(struct attr_iter, 1); } diff --git a/navit/mapset.h b/navit/mapset.h index 6f8917d04..df6c0d0a7 100644 --- a/navit/mapset.h +++ b/navit/mapset.h @@ -35,7 +35,7 @@ struct mapset_handle; struct mapset_search; struct mapset *mapset_new(struct attr *parent, struct attr **attrs); struct mapset *mapset_dup(struct mapset *ms); -struct attr_iter *mapset_attr_iter_new(void); +struct attr_iter *mapset_attr_iter_new(void * unused); void mapset_attr_iter_destroy(struct attr_iter *iter); int mapset_add_attr(struct mapset *ms, struct attr *attr); int mapset_remove_attr(struct mapset *ms, struct attr *attr); diff --git a/navit/maptool/maptool.c b/navit/maptool/maptool.c index 54a68135c..f18175990 100644 --- a/navit/maptool/maptool.c +++ b/navit/maptool/maptool.c @@ -255,7 +255,7 @@ static void add_plugin(char *path) { if (! plugins) { file_init(); - plugins=plugins_new(); + plugins=plugins_new(NULL, NULL); } pa_attr.u.str=path; pl_attr.u.plugins=plugins; diff --git a/navit/navigation.c b/navit/navigation.c index bc216ec15..1ddec7d33 100644 --- a/navit/navigation.c +++ b/navit/navigation.c @@ -4050,24 +4050,28 @@ static int navigation_map_item_attr_get(void *priv_data, enum attr_type attr_typ this_->str=attr->u.str=g_strdup_printf("delta:%d", cmd->delta); return 1; } + /* fall through */ case 3: this_->debug_idx++; if (prev) { this_->str=attr->u.str=g_strdup_printf("prev street_name:%s", prev->way.name); return 1; } + /* fall through */ case 4: this_->debug_idx++; if (prev) { this_->str=attr->u.str=g_strdup_printf("prev street_name_systematic:%s", prev->way.name_systematic); return 1; } + /* fall through */ case 5: this_->debug_idx++; if (prev) { this_->str=attr->u.str=g_strdup_printf("prev angle:(%d -) %d", prev->way.angle2, prev->angle_end); return 1; } + /* fall through */ case 6: this_->debug_idx++; this_->ways=itm->way.next; @@ -4075,6 +4079,7 @@ static int navigation_map_item_attr_get(void *priv_data, enum attr_type attr_typ this_->str=attr->u.str=g_strdup_printf("prev item type:%s", item_to_name(prev->way.item.type)); return 1; } + /* fall through */ case 7: if (this_->ways && prev) { this_->str=attr->u.str=g_strdup_printf("other item angle:%d delta:%d flags:%d dir:%d type:%s id:(0x%x,0x%x)", @@ -4084,6 +4089,7 @@ static int navigation_map_item_attr_get(void *priv_data, enum attr_type attr_typ return 1; } this_->debug_idx++; + /* fall through */ case 8: this_->debug_idx++; if (prev) { @@ -4108,6 +4114,7 @@ static int navigation_map_item_attr_get(void *priv_data, enum attr_type attr_typ maneuver->delta); return 1; } + /* fall through */ default: this_->attr_next=attr_none; diff --git a/navit/navit.c b/navit/navit.c index 63ed65807..50d639896 100644 --- a/navit/navit.c +++ b/navit/navit.c @@ -198,13 +198,12 @@ static int navit_add_vehicle(struct navit *this_, struct vehicle *v); static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init); static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir); static void navit_set_cursors(struct navit *this_); -static void navit_cmd_zoom_to_route(struct navit *this); -static void navit_cmd_set_center_cursor(struct navit *this_); -static void navit_cmd_announcer_toggle(struct navit *this_); +static int navit_cmd_zoom_to_route(struct navit *this, char *function, struct attr **in, struct attr ***out); +static int navit_cmd_set_center_cursor(struct navit *this_, char *function, struct attr **in, struct attr ***out); +static int navit_cmd_announcer_toggle(struct navit *this_, char *function, struct attr **in, struct attr ***out); static void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv); static int navit_set_vehicleprofile(struct navit *this_, struct vehicleprofile *vp); -static void navit_cmd_switch_layout_day_night(struct navit *this_, char *function, struct attr **in, struct attr ***out, - int valid); +static int navit_cmd_switch_layout_day_night(struct navit *this_, char *function, struct attr **in, struct attr ***out); struct object_func navit_func; struct navit *global_navit; @@ -830,22 +829,22 @@ void navit_zoom_out_cursor(struct navit *this_, int factor) { } else navit_zoom_out(this_, 2, NULL); } - -static int navit_cmd_zoom_in(struct navit *this_) { +static int navit_cmd_zoom_in(struct navit *this_, char *cmd, struct attr **in, struct attr ***out) { navit_zoom_in_cursor(this_, 2); return 0; } -static int navit_cmd_zoom_out(struct navit *this_) { +static int navit_cmd_zoom_out(struct navit *this_, char *cmd, struct attr **in, struct attr ***out) { navit_zoom_out_cursor(this_, 2); return 0; } -static void navit_cmd_say(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) { +static int navit_cmd_say(struct navit *this, char *function, struct attr **in, struct attr ***out) { if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) navit_say(this, in[0]->u.str); + return 0; } static GHashTable *cmd_int_var_hash = NULL; @@ -858,11 +857,9 @@ static GHashTable *cmd_attr_var_hash = NULL; * @param function unused (needed to match command function signature) * @param in input attributes in[0] is the key string, in[1] is the integer value to store * @param out output attributes, unused - * @param valid unused - * @returns nothing + * @returns 0 */ -static void navit_cmd_set_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, - int *valid) { +static int navit_cmd_set_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out) { char*key; struct attr*val; if(!cmd_int_var_hash) { @@ -876,6 +873,7 @@ static void navit_cmd_set_int_var(struct navit *this, char *function, struct att key = g_strdup(in[0]->u.str); g_hash_table_insert(cmd_int_var_hash, key, val); } + return 0; } @@ -886,11 +884,9 @@ static void navit_cmd_set_int_var(struct navit *this, char *function, struct att * @param function unused (needed to match command function signature) * @param in input attributes in[0] is the key string, in[1] is the attr* value to store * @param out output attributes, unused - * @param valid unused - * @returns nothing + * @returns 0 */ -static void navit_cmd_set_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, - int *valid) { +static int navit_cmd_set_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out) { char*key; struct attr*val; if(!cmd_attr_var_hash) { @@ -905,6 +901,7 @@ static void navit_cmd_set_attr_var(struct navit *this, char *function, struct at } else { dbg(lvl_warning, "Wrong parameters for set_attr_var() command function"); } + return 0; } @@ -917,10 +914,9 @@ static void navit_cmd_set_attr_var(struct navit *this, char *function, struct at * @param in input attribute in[0] is the name of the layer * @param out output unused * @param valid unused - * @returns nothing + * @returns 0 */ -static void navit_cmd_toggle_layer(struct navit *this, char *function, struct attr **in, struct attr ***out, - int *valid) { +static int navit_cmd_toggle_layer(struct navit *this, char *function, struct attr **in, struct attr ***out) { if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) { if(this->layout_current && this->layout_current->layers) { GList* layers = this->layout_current->layers; @@ -929,12 +925,13 @@ static void navit_cmd_toggle_layer(struct navit *this, char *function, struct at if(l && !strcmp(l->name,in[0]->u.str) ) { l->active ^= 1; navit_draw(this); - return; + return 0; } layers=g_list_next(layers); } } } + return 0; } /** @@ -944,11 +941,9 @@ static void navit_cmd_toggle_layer(struct navit *this, char *function, struct at * @param function unused (needed to match command function signature) * @param in input attribute in[0] is the name of the map * @param out output attribute, 0 on error or the id of the created item on success - * @param valid unused - * @returns nothing + * @returns 0 */ -static void navit_cmd_map_add_curr_pos(struct navit *this, char *function, struct attr **in, struct attr ***out, - int *valid) { +static int navit_cmd_map_add_curr_pos(struct navit *this, char *function, struct attr **in, struct attr ***out) { struct attr **list = g_new0(struct attr *,2); struct attr*val = g_new0(struct attr,1); struct mapset* ms; @@ -973,12 +968,12 @@ static void navit_cmd_map_add_curr_pos(struct navit *this, char *function, struc if(!(ms=navit_get_mapset(this))) { dbg(lvl_error, "Command function map_add_curr_pos(): there is no active mapset"); - return; + return 0; } if((item_type = item_from_name(in[1]->u.str))==type_none) { dbg(lvl_error, "Command function map_add_curr_pos(): unknown item type"); - return; + return 0; } curr_map = mapset_get_map_by_name(ms, in[0]->u.str); @@ -986,7 +981,7 @@ static void navit_cmd_map_add_curr_pos(struct navit *this, char *function, struc //no map with the given name found if( ! curr_map) { dbg(lvl_error, "Command function map_add_curr_pos(): map not found"); - return; + return 0; } if(this->vehicle && this->vehicle->vehicle ) { @@ -995,11 +990,11 @@ static void navit_cmd_map_add_curr_pos(struct navit *this, char *function, struc transform_from_geo(projection_mg, pos_attr.u.coord_geo, &curr_coord); } else { dbg(lvl_error, "Command function map_add_curr_pos(): vehicle position is not accessible"); - return; + return 0; } } else { dbg(lvl_error, "Command function map_add_curr_pos(): no vehicle"); - return; + return 0; } sel.next=NULL; @@ -1025,6 +1020,7 @@ static void navit_cmd_map_add_curr_pos(struct navit *this, char *function, struc } map_rect_destroy(mr); } + return 0; } /** @@ -1034,11 +1030,9 @@ static void navit_cmd_map_add_curr_pos(struct navit *this, char *function, struc * @param function unused (needed to match command function signature) * @param in input attribute in[0] - name of the map ; in[1] - item ; in[2] - attr name ; in[3] - attr value * @param out output attribute, 0 on error, 1 on success - * @param valid unused - * @returns nothing + * @returns 0 */ -static void navit_cmd_map_item_set_attr(struct navit *this, char *function, struct attr **in, struct attr ***out, - int *valid) { +static int navit_cmd_map_item_set_attr(struct navit *this, char *function, struct attr **in, struct attr ***out) { if ( in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str &&//map name in[1] && ATTR_IS_ITEM(in[1]->type) && in[2]->u.item &&//item @@ -1069,7 +1063,7 @@ static void navit_cmd_map_item_set_attr(struct navit *this, char *function, stru curr_map = mapset_get_map_by_name(ms, in[0]->u.str); if( ! curr_map) { - return; + return 0; } mr=map_rect_new(curr_map,NULL); @@ -1090,6 +1084,7 @@ static void navit_cmd_map_item_set_attr(struct navit *this, char *function, stru dbg(lvl_debug,"Command function item_set_attr(): attr val cond: %d",(in[3] && ATTR_IS_STRING(in[3]->type) && in[3]->u.str)?1:0); } + return 0; } /** @@ -1099,11 +1094,9 @@ static void navit_cmd_map_item_set_attr(struct navit *this, char *function, stru * @param function unused (needed to match command function signature) * @param in input attribute in[0] is the key string * @param out output attribute, the attr for the given key string if exists or NULL - * @param valid unused - * @returns nothing + * @returns 0 */ -static void navit_cmd_get_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, - int *valid) { +static int navit_cmd_get_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out) { struct attr **list = g_new0(struct attr *,2); list[1] = NULL; *out = list; @@ -1112,7 +1105,7 @@ static void navit_cmd_get_attr_var(struct navit *this, char *function, struct at val->type = attr_type_item_begin; val->u.item = NULL; list[0] = val; - return; + return 0; } if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) { struct attr*ret = g_hash_table_lookup(cmd_attr_var_hash, in[0]->u.str); @@ -1125,6 +1118,7 @@ static void navit_cmd_get_attr_var(struct navit *this, char *function, struct at list[0] = val; } } + return 0; } @@ -1135,11 +1129,9 @@ static void navit_cmd_get_attr_var(struct navit *this, char *function, struct at * @param function unused (needed to match command function signature) * @param in input attribute in[0] is the key string * @param out output attribute, the value for the given key string if exists or 0 - * @param valid unused - * @returns nothing + * @returns 0 */ -static void navit_cmd_get_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, - int *valid) { +static int navit_cmd_get_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out) { struct attr **list = g_new0(struct attr *,2); list[1] = NULL; *out = list; @@ -1148,7 +1140,7 @@ static void navit_cmd_get_int_var(struct navit *this, char *function, struct att val->type = attr_type_int_begin; val->u.num = 0; list[0] = val; - return; + return 0; } if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) { struct attr*ret = g_hash_table_lookup(cmd_int_var_hash, in[0]->u.str); @@ -1161,6 +1153,7 @@ static void navit_cmd_get_int_var(struct navit *this, char *function, struct att list[0] = val; } } + return 0; } GList *cmd_int_var_stack = NULL; @@ -1172,15 +1165,15 @@ GList *cmd_int_var_stack = NULL; * @param function unused (needed to match command function signature) * @param in input attribute in[0] is the integer attibute to push * @param out output attributes, unused - * @param valid unused - * @returns nothing + * @returns 0 */ -static void navit_cmd_push_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) { +static int navit_cmd_push_int(struct navit *this, char *function, struct attr **in, struct attr ***out) { if (in && in[0] && ATTR_IS_NUMERIC(in[0]->type)) { struct attr*val = g_new(struct attr,1); attr_dup_content(in[0],val); cmd_int_var_stack = g_list_prepend(cmd_int_var_stack, val); } + return 0; } /** @@ -1190,10 +1183,9 @@ static void navit_cmd_push_int(struct navit *this, char *function, struct attr * * @param function unused (needed to match command function signature) * @param in input attributes unused * @param out output attribute, the value popped if stack isn't empty or 0 - * @param valid unused - * @returns nothing + * @returns 0 */ -static void navit_cmd_pop_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) { +static int navit_cmd_pop_int(struct navit *this, char *function, struct attr **in, struct attr ***out) { struct attr **list = g_new0(struct attr *,2); if(!cmd_int_var_stack) { struct attr*val = g_new0(struct attr,1); @@ -1206,6 +1198,7 @@ static void navit_cmd_pop_int(struct navit *this, char *function, struct attr ** } list[1] = NULL; *out = list; + return 0; } /** @@ -1215,11 +1208,9 @@ static void navit_cmd_pop_int(struct navit *this, char *function, struct attr ** * @param function unused (needed to match command function signature) * @param in input attributes unused * @param out output attribute, the size of stack - * @param valid unused - * @returns nothing + * @returns 0 */ -static void navit_cmd_int_stack_size(struct navit *this, char *function, struct attr **in, struct attr ***out, - int *valid) { +static int navit_cmd_int_stack_size(struct navit *this, char *function, struct attr **in, struct attr ***out) { struct attr **list; struct attr *attr = g_new0(struct attr,1); attr->type = attr_type_int_begin; @@ -1233,6 +1224,7 @@ static void navit_cmd_int_stack_size(struct navit *this, char *function, struct list[1] = NULL; *out = list; cmd_int_var_stack = g_list_remove_link(cmd_int_var_stack,cmd_int_var_stack); + return 0; } static struct attr ** navit_get_coord(struct navit *this, struct attr **in, struct pcoord *pc) { @@ -1268,63 +1260,64 @@ static struct attr ** navit_get_coord(struct navit *this, struct attr **in, stru return in; } -static void navit_cmd_set_destination(struct navit *this, char *function, struct attr **in, struct attr ***out, - int *valid) { +static int navit_cmd_set_destination(struct navit *this, char *function, struct attr **in, struct attr ***out) { struct pcoord pc; char *description=NULL; in=navit_get_coord(this, in, &pc); if (!in) - return; + return 0; if (in[0] && ATTR_IS_STRING(in[0]->type)) description=in[0]->u.str; navit_set_destination(this, &pc, description, 1); + return 0; } -static void navit_cmd_route_remove_next_waypoint(struct navit *this, char *function, struct attr **in, - struct attr ***out, - int *valid) { +static int navit_cmd_route_remove_next_waypoint(struct navit *this, char *function, struct attr **in, + struct attr ***out) { navit_remove_waypoint(this); + return 0; } -static void navit_cmd_route_remove_last_waypoint(struct navit *this, char *function, struct attr **in, - struct attr ***out, - int *valid) { +static int navit_cmd_route_remove_last_waypoint(struct navit *this, char *function, struct attr **in, + struct attr ***out) { navit_remove_nth_waypoint(this, navit_get_destination_count(this)-1); + return 0; } -static void navit_cmd_set_center(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) { +static int navit_cmd_set_center(struct navit *this, char *function, struct attr **in, struct attr ***out) { struct pcoord pc; int set_timeout=0; in=navit_get_coord(this, in, &pc); if (!in) - return; + return 0; if(in[0] && ATTR_IS_INT(in[0]->type)) set_timeout=in[0]->u.num!=0; navit_set_center(this, &pc, set_timeout); + return 0; } -static void navit_cmd_set_position(struct navit *this, char *function, struct attr **in, struct attr ***out, - int *valid) { +static int navit_cmd_set_position(struct navit *this, char *function, struct attr **in, struct attr ***out) { struct pcoord pc; in=navit_get_coord(this, in, &pc); if (!in) - return; + return 0; navit_set_position(this, &pc); + return 0; } -static void navit_cmd_fmt_coordinates(struct navit *this, char *function, struct attr **in, struct attr ***out, - int *valid) { +static int navit_cmd_fmt_coordinates(struct navit *this, char *function, struct attr **in, struct attr ***out) { struct attr attr; attr.type=attr_type_string_begin; attr.u.str="Fix me"; if (out) { *out=attr_generic_add_attr(*out, &attr); } + return 0; } /** @@ -1334,10 +1327,9 @@ static void navit_cmd_fmt_coordinates(struct navit *this, char *function, struct * @param function unused (needed to match command function signature) * @param in input attributes in[0] - separator, in[1..] - attributes to join * @param out output attribute joined attribute as string - * @param valid unused - * @returns nothing + * @returns 0 */ -static void navit_cmd_strjoin(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) { +static int navit_cmd_strjoin(struct navit *this, char *function, struct attr **in, struct attr ***out) { struct attr attr; gchar *ret, *sep; int i; @@ -1360,6 +1352,7 @@ static void navit_cmd_strjoin(struct navit *this, char *function, struct attr ** } g_free(ret); } + return 0; } /** @@ -1369,10 +1362,9 @@ static void navit_cmd_strjoin(struct navit *this, char *function, struct attr ** * @param function unused (needed to match command function signature) * @param in input attributes in[0] - name of executable, in[1..] - parameters * @param out output attribute unused - * @param valid unused - * @returns nothing + * @returns 0 */ -static void navit_cmd_spawn(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) { +static int navit_cmd_spawn(struct navit *this, char *function, struct attr **in, struct attr ***out) { int i,j, nparms, nvalid; char ** argv=NULL; struct spawn_process_info *pi; @@ -1418,6 +1410,7 @@ static void navit_cmd_spawn(struct navit *this, char *function, struct attr **in g_free(argv[i]); g_free(argv); } + return 0; } @@ -1887,12 +1880,12 @@ void navit_say(struct navit *this_, const char *text) { * @brief Toggles the navigation announcer for navit * @param this_ The navit object */ -static void navit_cmd_announcer_toggle(struct navit *this_) { +static int navit_cmd_announcer_toggle(struct navit *this_, char *function, struct attr **in, struct attr ***out) { struct attr attr, speechattr; // search for the speech attribute if(!navit_get_attr(this_, attr_speech, &speechattr, NULL)) - return; + return 0; // find out if the corresponding attribute attr_active has been set if(speech_get_attr(speechattr.u.speech, attr_active, &attr, NULL)) { // flip it then... @@ -1905,10 +1898,11 @@ static void navit_cmd_announcer_toggle(struct navit *this_) { // apply the new state if(!speech_set_attr(speechattr.u.speech, &attr)) - return; + return 0; // announce that the speech attribute has changed callback_list_call_attr_1(this_->attr_cbl, attr_speech, this_); + return 0; } void navit_speak(struct navit *this_) { @@ -2058,7 +2052,7 @@ void navit_window_roadbook_new(struct navit *this_) { navit_window_roadbook_update(this_); } -void navit_init(struct navit *this_) { +int navit_init(struct navit *this_) { struct mapset *ms; struct map *map; int callback; @@ -2135,7 +2129,7 @@ void navit_init(struct navit *this_) { } attr = g_new0(struct attr, 1); - iter = navit_attr_iter_new(); + iter = navit_attr_iter_new(NULL); map = NULL; while (navit_get_attr(this_, attr_traffic, attr, iter)) { traffic = (struct traffic *) attr->u.navit_object; @@ -2213,6 +2207,7 @@ void navit_init(struct navit *this_) { navit_draw_async(this_, 1); if (callback) callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_); + return 0; } void navit_zoom_to_rect(struct navit *this_, struct coord_rect *r) { @@ -2280,8 +2275,9 @@ void navit_zoom_to_route(struct navit *this_, int orientation) { navit_zoom_to_rect(this_, &r); } -static void navit_cmd_zoom_to_route(struct navit *this) { +static int navit_cmd_zoom_to_route(struct navit *this, char *function, struct attr **in, struct attr ***out) { navit_zoom_to_route(this, 0); + return 0; } @@ -2484,8 +2480,9 @@ static void navit_set_center_cursor_draw(struct navit *this_) { * *@param this_ The navit object */ -static void navit_cmd_set_center_cursor(struct navit *this_) { +static int navit_cmd_set_center_cursor(struct navit *this_, char *function, struct attr **in, struct attr ***out) { navit_set_center_cursor_draw(this_); + return 0; } void navit_set_center_screen(struct navit *this_, struct point *p, int set_timeout) { @@ -2951,7 +2948,7 @@ struct layout *navit_get_layout_by_name(struct navit *this_, const char *layout_ if (!layout_name) return NULL; - iter=navit_attr_iter_new(); + iter=navit_attr_iter_new(NULL); while (navit_get_attr(this_, attr_layout, &layout_attr, iter)) { if (strcmp(layout_attr.u.layout->name, layout_name) == 0) { result = layout_attr.u.layout; @@ -3112,7 +3109,7 @@ int navit_remove_attr(struct navit *this_, struct attr *attr) { } struct attr_iter * -navit_attr_iter_new(void) { +navit_attr_iter_new(void * unused) { return g_new0(struct attr_iter, 1); } @@ -3529,7 +3526,6 @@ void navit_layout_switch(struct navit *n) { * @param function unused * @param in input attributes in[0], a string, see usage below * @param out output attribute unused - * @param valid unused * * * usage : @@ -3543,20 +3539,19 @@ void navit_layout_switch(struct navit *n) { * the version of the active layout (day/night/undefined) */ static -void navit_cmd_switch_layout_day_night(struct navit *this_, char *function, struct attr **in, struct attr ***out, - int valid) { +int navit_cmd_switch_layout_day_night(struct navit *this_, char *function, struct attr **in, struct attr *** out) { if (!(in && in[0] && ATTR_IS_STRING(in[0]->type))) { - return; + return 0; } dbg(lvl_debug," called with mode =%s",in[0]->u.str); if (!this_->layout_current) - return; + return 0; if (!this_->vehicle) - return; + return 0; if (!strcmp(in[0]->u.str,"manual")) { this_->auto_switch = FALSE; @@ -3585,7 +3580,7 @@ void navit_cmd_switch_layout_day_night(struct navit *this_, char *function, stru } dbg(lvl_debug,"auto = %i",this_->auto_switch); - return; + return 0; } int navit_set_vehicle_by_name(struct navit *n,const char *name) { @@ -3593,7 +3588,7 @@ int navit_set_vehicle_by_name(struct navit *n,const char *name) { struct attr_iter *iter; struct attr vehicle_attr, name_attr; - iter=navit_attr_iter_new(); + iter=navit_attr_iter_new(NULL); while (navit_get_attr(n,attr_vehicle,&vehicle_attr,iter)) { v=vehicle_attr.u.vehicle; @@ -3703,7 +3698,7 @@ void navit_destroy(struct navit *this_) { cmd_attr_var_hash=NULL; } if(cmd_int_var_stack) { - g_list_foreach(cmd_int_var_stack, (GFunc)attr_free, NULL); + g_list_foreach(cmd_int_var_stack, (GFunc)attr_free_g, NULL); g_list_free(cmd_int_var_stack); cmd_int_var_stack=NULL; } diff --git a/navit/navit.h b/navit/navit.h index f543a7baf..d715d814d 100644 --- a/navit/navit.h +++ b/navit/navit.h @@ -98,7 +98,7 @@ void navit_say(struct navit *this_, const char *text); void navit_speak(struct navit *this_); void navit_window_roadbook_destroy(struct navit *this_); void navit_window_roadbook_new(struct navit *this_); -void navit_init(struct navit *this_); +int navit_init(struct navit *this_); void navit_zoom_to_rect(struct navit *this_, struct coord_rect *r); void navit_zoom_to_route(struct navit *this_, int orientation); void navit_set_center(struct navit *this_, struct pcoord *center, int set_timeout); @@ -110,7 +110,7 @@ struct layout *navit_get_layout_by_name(struct navit *this_, const char *layout_ void navit_update_current_layout(struct navit *this_, struct layout *layout); int navit_add_attr(struct navit *this_, struct attr *attr); int navit_remove_attr(struct navit *this_, struct attr *attr); -struct attr_iter *navit_attr_iter_new(void); +struct attr_iter *navit_attr_iter_new(void * unused); void navit_attr_iter_destroy(struct attr_iter *iter); void navit_add_callback(struct navit *this_, struct callback *cb); void navit_remove_callback(struct navit *this_, struct callback *cb); diff --git a/navit/plugin.c b/navit/plugin.c index 82fcc61c5..259d8e7e6 100644 --- a/navit/plugin.c +++ b/navit/plugin.c @@ -220,7 +220,7 @@ void plugin_destroy(struct plugin *pl) { } struct plugins * -plugins_new(void) { +plugins_new(struct attr * in, struct attr ** out) { struct plugins *ret=g_new0(struct plugins, 1); ret->hash=g_hash_table_new(g_str_hash, g_str_equal); pls=ret; @@ -300,7 +300,7 @@ plugin_new(struct attr *parent, struct attr **attrs) { #endif } -void plugins_init(struct plugins *pls) { +int plugins_init(struct plugins *pls) { #ifdef USE_PLUGINS struct plugin *pl; GList *l; @@ -322,6 +322,7 @@ void plugins_init(struct plugins *pls) { dbg(lvl_error, "Warning: No plugins found. Is Navit installed correctly?"); } #endif + return 0; } void plugins_destroy(struct plugins *pls) { diff --git a/navit/plugin.h b/navit/plugin.h index 5c9636aa2..911daa440 100644 --- a/navit/plugin.h +++ b/navit/plugin.h @@ -33,26 +33,26 @@ struct plugin; * offered by a plugin. */ enum plugin_category { - /** Category for plugins which implement a graphics backend. */ - plugin_category_graphics, - /** Category for plugins which implement a GUI frontend. */ - plugin_category_gui, - /** Category for plugins which implement a driver for providing/loading map data. */ - plugin_category_map, - /** Category for plugins which implement an OSD. */ - plugin_category_osd, - /** Category for plugins which implement speech output. */ - plugin_category_speech, - /** Category for plugins which supply position data (typically from a GPS receiver). */ - plugin_category_vehicle, - /** Category for plugins which implement/wrap an event subsystem. */ - plugin_category_event, - /** Category for plugins which load fonts. */ - plugin_category_font, - /** Category for plugins which retrieve traffic information. */ - plugin_category_traffic, - /** Dummy for last entry. */ - plugin_category_last, + /** Category for plugins which implement a graphics backend. */ + plugin_category_graphics, + /** Category for plugins which implement a GUI frontend. */ + plugin_category_gui, + /** Category for plugins which implement a driver for providing/loading map data. */ + plugin_category_map, + /** Category for plugins which implement an OSD. */ + plugin_category_osd, + /** Category for plugins which implement speech output. */ + plugin_category_speech, + /** Category for plugins which supply position data (typically from a GPS receiver). */ + plugin_category_vehicle, + /** Category for plugins which implement/wrap an event subsystem. */ + plugin_category_event, + /** Category for plugins which load fonts. */ + plugin_category_font, + /** Category for plugins which retrieve traffic information. */ + plugin_category_traffic, + /** Dummy for last entry. */ + plugin_category_last, }; #endif @@ -95,8 +95,8 @@ void plugin_call_##name(t1 p1,t2 p2, t3 p3, t4 p4) PLUGIN_CALL(name,p1,p2,p3,p4) PLUGIN_REGISTER(name,t1 p1,t2 p2,t3 p3,t4 p4) struct name_val { - char *name; - void *val; + char *name; + void *val; }; GList *plugin_categories[plugin_category_last]; @@ -162,9 +162,9 @@ void plugin_set_lazy(struct plugin *pl, int lazy); void plugin_call_init(struct plugin *pl); void plugin_unload(struct plugin *pl); void plugin_destroy(struct plugin *pl); -struct plugins *plugins_new(void); +struct plugins *plugins_new(struct attr *, struct attr **); struct plugin *plugin_new(struct attr *parent, struct attr ** attrs); -void plugins_init(struct plugins *pls); +int plugins_init(struct plugins *pls); void plugins_destroy(struct plugins *pls); void *plugin_get_category(enum plugin_category category, const char *category_name, const char *name); /* end of prototypes */ diff --git a/navit/popup.c b/navit/popup.c index 49f379853..79d997b46 100644 --- a/navit/popup.c +++ b/navit/popup.c @@ -108,7 +108,7 @@ static void popup_traffic_distortion_delay(struct item *item, int delay) { static void popup_set_destination(struct navit *nav, struct pcoord *pc) { struct coord c; struct coord_geo g; - char buffer[1024]; + char buffer[1024 +10]; /* +10 for "Map Point "*/ char buffer_geo[1024]; c.x = pc->x; c.y = pc->y; @@ -141,7 +141,7 @@ static void popup_set_bookmark(struct navit *nav, struct pcoord *pc) { struct attr attr; struct coord c; struct coord_geo g; - char buffer[1024]; + char buffer[1024 + 10]; /* + 10 for "Map Point " */ char buffer_geo[1024]; c.x = pc->x; c.y = pc->y; diff --git a/navit/route.c b/navit/route.c index 6ee352c65..652ae6d54 100644 --- a/navit/route.c +++ b/navit/route.c @@ -1072,8 +1072,13 @@ static void route_free_selection(struct map_selection *sel) { } +/* for compatibility to GFunc */ +static void route_info_free_g(struct route_info *inf, void * unused) { + route_info_free(inf); +} + static void route_clear_destinations(struct route *this_) { - g_list_foreach(this_->destinations, (GFunc)route_info_free, NULL); + g_list_foreach(this_->destinations, (GFunc)route_info_free_g, NULL); g_list_free(this_->destinations); this_->destinations=NULL; } diff --git a/navit/traffic.c b/navit/traffic.c index 035707934..9705abbdd 100644 --- a/navit/traffic.c +++ b/navit/traffic.c @@ -3408,7 +3408,7 @@ static int traffic_message_restore_segments(struct traffic_message * this_, stru struct map_rect * mr; struct item * map_item; int * default_flags; - int item_flags, segmented, maxspeed; + int item_flags, segmented, maxspeed=INT_MAX; struct coord map_c; /* @@ -4152,7 +4152,7 @@ static void traffic_set_shared(struct traffic *this_) { dbg(lvl_debug, "enter"); if (!this_->shared) { - iter = navit_attr_iter_new(); + iter = navit_attr_iter_new(NULL); while (navit_get_attr(this_->navit, attr_traffic, &attr, iter)) { traffic = (struct traffic *) attr.u.navit_object; if (traffic->shared) diff --git a/navit/xmlconfig.c b/navit/xmlconfig.c index 476997c2d..c47c82163 100644 --- a/navit/xmlconfig.c +++ b/navit/xmlconfig.c @@ -1304,13 +1304,14 @@ navit_object_ref(struct navit_object *obj) { return obj; } -void navit_object_unref(struct navit_object *obj) { +void* navit_object_unref(struct navit_object *obj) { if (obj) { obj->refcount--; dbg(lvl_debug,"refcount %s %p %d",attr_to_name(obj->func->type),obj,obj->refcount); if (obj->refcount <= 0 && obj->func && obj->func->destroy) obj->func->destroy(obj); } + return NULL; } struct attr_iter { @@ -1318,7 +1319,7 @@ struct attr_iter { }; struct attr_iter * -navit_object_attr_iter_new(void) { +navit_object_attr_iter_new(void * unused) { return g_new0(struct attr_iter, 1); } diff --git a/navit/xmlconfig.h b/navit/xmlconfig.h index 56f118eb2..d5697d53c 100644 --- a/navit/xmlconfig.h +++ b/navit/xmlconfig.h @@ -78,54 +78,56 @@ typedef void *(*object_func_unref)(void *); * see fit. */ struct object_func { - enum attr_type type; /**< The object type */ - void *(*create)(struct attr *parent, struct attr **attrs); /**< Function to create a new object instance */ - int (*get_attr)(void *, enum attr_type type, struct attr *attr, struct attr_iter *iter); /**< Function + enum attr_type type; /**< The object type */ + void *(*create)(struct attr *parent, struct attr **attrs); /**< Function to create a new object instance */ + int (*get_attr)(void *, enum attr_type type, struct attr *attr, struct attr_iter *iter); /**< Function * to get an attribute of the object, * set to `navit_object_get_attr` for default behavior */ - struct attr_iter *(*iter_new)(void *); /**< Function to obtain a new attribute iterator, + struct attr_iter *(*iter_new)(void *); /**< Function to obtain a new attribute iterator, * set to `navit_object_attr_iter_new` for default * behavior, can be NULL for some object types */ - void (*iter_destroy)(struct attr_iter *); /**< Function to destroy an attribute iterator, + void (*iter_destroy)(struct attr_iter *); /**< Function to destroy an attribute iterator, * set to `navit_object_attr_iter_destroy` for default * behavior, can be NULL for some object types */ - int (*set_attr)(void *, struct attr *attr); /**< Function to set an attribute, + int (*set_attr)(void *, struct attr *attr); /**< Function to set an attribute, * set to `navit_object_set_attr` for default behavior, * can be NULL for some object types */ - int (*add_attr)(void *, struct attr *attr); /**< Function to add an attribute, + int (*add_attr)(void *, struct attr *attr); /**< Function to add an attribute, * set to `navit_object_add_attr` for default behavior, * can be NULL for some object types */ - int (*remove_attr)(void *, struct attr *attr); /**< Function to remove an attribute, + int (*remove_attr)(void *, struct attr *attr); /**< Function to remove an attribute, * set to `navit_object_remove_attr` for default behavior, * can be NULL for some object types */ - int (*init)(void *); /**< TODO, + int (*init)(void *); /**< TODO, * can be NULL for some object types */ - void (*destroy)(void *); /**< Function to destroy an object instance, + void (*destroy)(void *); /**< Function to destroy an object instance, * set to `navit_object_destroy` for default behavior, * can be NULL */ - void *(*dup)(void *); /**< Function to create a copy of an object instance */ - void *(*ref)(void *); /**< Function to increase the reference count for an + void *(*dup)(void *); /**< Function to create a copy of an object instance */ + void *(*ref)(void *); /**< Function to increase the reference count for an * object instance, set to `navit_object_ref` for * default behavior, can be NULL for some object types */ - void *(*unref)(void *); /**< Function to decrease the reference count for an + void *(*unref)(void *); /**< Function to decrease the reference count for an * object instance, set to `navit_object_unref` for * default behavior, can be NULL for some object types */ }; -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, speech_func, navigation_func, route_func, traffic_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, + speech_func, navigation_func, route_func, traffic_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 || (x) == attr_log || (x) == attr_speech || (x) == attr_navigation || (x) == attr_route) #define NAVIT_OBJECT struct object_func *func; int refcount; struct attr **attrs; struct navit_object { - NAVIT_OBJECT + NAVIT_OBJECT }; 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); +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); void navit_object_callbacks(struct navit_object *obj, struct attr *attr); @@ -140,10 +142,12 @@ typedef GError xmlerror; enum attr_type; struct object_func *object_func_lookup(enum attr_type type); 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 **)); -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 **)); + 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 **)); +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 **)); gboolean config_load(const char *filename, xmlerror **error); //static void xinclude(GMarkupParseContext *context, const gchar **attribute_names, const gchar **attribute_values, struct xmldocument *doc_old, xmlerror **error); |