2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
27 #include <sys/types.h>
41 #include "xmlconfig.h"
45 #include "navigation.h"
47 #include "navit_nls.h"
49 struct map_data *map_data_default;
51 static void sigchld(int sig)
53 #if !defined(_WIN32) && !defined(__CEGCC__)
55 while (waitpid(-1, &status, WNOHANG) > 0);
60 gchar *get_home_directory(void)
62 static gchar *homedir = NULL;
64 if (homedir) return homedir;
65 homedir = getenv("HOME");
68 dbg(0,"Could not find home directory. Using current directory as home directory.");
71 homedir=g_strdup(homedir);
85 struct iter *ret=g_new0(struct iter, 1);
91 main_iter_destroy(struct iter *iter)
97 main_get_navit(struct iter *iter)
100 struct navit *ret=NULL;
106 ret=(struct navit *)(list->data);
108 iter->list=g_list_next(iter->list);
114 main_add_navit(struct navit *nav)
116 navit=g_list_prepend(navit, nav);
120 main_remove_navit(struct navit *nav)
122 navit=g_list_remove(navit, nav);
124 event_main_loop_quit();
128 main_init(char *program)
130 GError *error = NULL;
131 char *config_file = NULL;
135 GList *list = NULL, *li;
139 signal(SIGCHLD, sigchld);
142 setenv("LC_NUMERIC","C",1);
143 setlocale(LC_ALL,"");
144 setlocale(LC_NUMERIC,"C");
145 if (file_exists("navit.c") || file_exists("navit.o") || file_exists("navit.lo")) {
146 char buffer[PATH_MAX];
147 printf(_("Running from source directory\n"));
148 getcwd(buffer, PATH_MAX);
149 setenv("NAVIT_PREFIX", buffer, 0);
150 setenv("NAVIT_LIBDIR", buffer, 0);
151 setenv("NAVIT_SHAREDIR", buffer, 0);
152 setenv("NAVIT_LIBPREFIX", "*/.libs/", 0);
153 s=g_strdup_printf("%s/../locale", buffer);
154 setenv("NAVIT_LOCALEDIR", s, 0);
156 setenv("NAVIT_USER_DATADIR", "./", 0);
158 if (!getenv("NAVIT_PREFIX")) {
160 if (l > 10 && !strcmp(program+l-10,"/bin/navit")) {
163 if (strcmp(s, PREFIX))
164 printf(_("setting '%s' to '%s'\n"), "NAVIT_PREFIX", s);
165 setenv("NAVIT_PREFIX", s, 0);
168 setenv("NAVIT_PREFIX", PREFIX, 0);
171 s=g_strdup_printf("locale");
173 s=g_strdup_printf("%s/share/locale", getenv("NAVIT_PREFIX"));
175 setenv("NAVIT_LOCALEDIR", s, 0);
178 s=g_strdup_printf(".");
180 s=g_strdup_printf("%s/share/navit", getenv("NAVIT_PREFIX"));
182 setenv("NAVIT_SHAREDIR", s, 0);
184 s=g_strdup_printf("%s/lib/navit", getenv("NAVIT_PREFIX"));
185 setenv("NAVIT_LIBDIR", s, 0);
187 setenv("NAVIT_USER_DATADIR", g_strjoin(NULL, get_home_directory(), "/.navit/", NULL), 0);
189 if (getenv("LC_ALL"))
190 dbg(0,"Warning: LC_ALL is set, this might lead to problems\n");
191 s = getenv("NAVIT_WID");
193 setenv("SDL_WINDOWID", s, 0);
200 bindtextdomain(PACKAGE, getenv("NAVIT_LOCALEDIR"));
201 bind_textdomain_codeset (PACKAGE, "UTF-8");