Add:Core:Added support for atoms
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 2 Jan 2009 17:27:24 +0000 (17:27 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 2 Jan 2009 17:27:24 +0000 (17:27 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1878 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/Makefile.am
navit/navit/atom.c [new file with mode: 0644]
navit/navit/atom.h [new file with mode: 0644]
navit/navit/start.c

index c6a55e3..ae1a339 100644 (file)
@@ -18,11 +18,11 @@ pkgdata_DATA = navit.xml
 EXTRA_DIST = navit.xml 
 
 noinst_LTLIBRARIES        = libnavit.la
-libnavit_la_SOURCES = attr.c cache.c callback.c compass.c coord.c country.c cursor.c data_window.c debug.c \
+libnavit_la_SOURCES = atom.c attr.c cache.c callback.c compass.c coord.c country.c cursor.c data_window.c debug.c \
        event.c event_glib.h file.c graphics.c gui.c item.c layout.c log.c main.c map.c \
        mapset.c maptype.c menu.c navit.c navigation.c osd.c param.c phrase.c plugin.c popup.c \
        profile.c projection.c route.c search.c speech.c transform.c track.c \
-       util.c vehicle.c xmlconfig.c attr.h attr_def.h cache.h callback.h color.h compass.h coord.h country.h \
+       util.c vehicle.c xmlconfig.c atom.h attr.h attr_def.h cache.h callback.h color.h compass.h coord.h country.h \
        cursor.h data.h data_window.h data_window_int.h debug.h destination.h draw_info.h endianess.h event.h \
        file.h graphics.h gtkext.h gui.h item.h item_def.h keys.h log.h layer.h layout.h main.h map-share.h map.h\
        map_data.h mapset.h maptype.h menu.h navigation.h navit.h osd.h \
diff --git a/navit/navit/atom.c b/navit/navit/atom.c
new file mode 100644 (file)
index 0000000..d225797
--- /dev/null
@@ -0,0 +1,27 @@
+#include <glib.h>
+#include "atom.h"
+
+static GHashTable *atom_hash;
+
+char *
+atom_lookup(char *name)
+{
+       return g_hash_table_lookup(atom_hash,name);
+}
+
+char *
+atom(char *name)
+{
+       char *id=atom_lookup(name);
+       if (id)
+               return id;
+       id=g_strdup(name);
+       g_hash_table_insert(atom_hash, id, id);
+       return id;
+}
+
+void
+atom_init(void)
+{
+       atom_hash=g_hash_table_new(g_str_hash, g_str_equal);
+}
diff --git a/navit/navit/atom.h b/navit/navit/atom.h
new file mode 100644 (file)
index 0000000..0cad37e
--- /dev/null
@@ -0,0 +1,3 @@
+char * atom_lookup(char *name);
+char * atom(char *name);
+void atom_init(void);
index 8e72883..a293d8e 100644 (file)
@@ -78,6 +78,7 @@ int main(int argc, char **argv)
 #ifdef HAVE_GLIB
        event_glib_init();
 #endif
+       atom_init();
        main_init(argv[0]);
        main_init_nls();
        debug_init(argv[0]);