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.
30 #include "navigation.h"
34 #include "event_glib.h"
35 #include "xmlconfig.h"
38 #include "navit_nls.h"
40 #ifdef HAVE_API_WIN32_CE
45 char *version=PACKAGE_VERSION" "SVN_VERSION""NAVIT_VARIANT;
50 printf(_("navit usage:\nnavit [options] [configfile]\n\t-c <file>: use <file> as config file\n\t-d <n>: set the debug output level to <n>. (TODO)\n\t-h: print this usage info and exit.\n\t-v: Print the version and exit.\n"));
54 int main_real(int argc, char **argv)
56 xmlerror *error = NULL;
57 char *config_file = NULL;
61 GList *list = NULL, *li;
72 cp = getenv("NAVIT_LOGFILE");
74 debug_set_logfile(cp);
75 #ifdef HAVE_API_WIN32_CE
77 debug_set_logfile("/Storage Card/navit.log");
81 extern void builtin_init(void);
90 opterr=0; //don't bomb out on errors.
92 /* DEVELOPPERS : don't forget to update the manpage if you modify theses options */
93 while((opt = getopt(argc, argv, ":hvc:d:")) != -1) {
100 printf("%s %s\n", "navit", version);
104 printf("config file n is set to `%s'\n", optarg);
105 config_file = optarg;
108 printf("TODO Verbose option is set to `%s'\n", optarg);
111 fprintf(stderr, "navit: Error - Option `%c' needs a value\n", optopt);
116 fprintf(stderr, "navit: Error - No such option: `%c'\n", optopt);
122 // use 1st cmd line option that is left for the config file
123 if (optind < argc) config_file = argv[optind];
125 // if config file is explicitely given only look for it, otherwise try std paths
126 if (config_file) list = g_list_append(list,g_strdup(config_file));
128 list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_USER_DATADIR"), "/navit.xml" , NULL));
129 list = g_list_append(list,g_strdup("navit.xml.local"));
130 list = g_list_append(list,g_strdup("navit.xml"));
131 #ifdef HAVE_API_ANDROID
132 list = g_list_append(list,g_strdup("/sdcard/navit.xml"));
134 list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml.local" , NULL));
135 list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml" , NULL));
137 list = g_list_append(list,g_strdup("/etc/navit/navit.xml"));
143 // We have not found an existing config file from all possibilities
144 dbg(0,_("No config file navit.xml, navit.xml.local found\n"));
147 // Try the next config file possibility from the list
148 config_file = li->data;
149 if (file_exists(config_file))
153 li = g_list_next(li);
156 if (!config_load(config_file, &error)) {
157 dbg(0, _("Error parsing '%s': %s\n"), config_file, error ? error->message : "");
159 dbg(0, _("Using '%s'\n"), config_file);
163 li = g_list_next(li);
166 if (! main_get_navit(NULL)) {
167 dbg(0, _("No instance has been created, exiting\n"));
170 event_main_loop_run();