… | |
… | |
70 | |
70 | |
71 | char *version=PACKAGE_VERSION" "SVN_VERSION""NAVIT_VARIANT; |
71 | char *version=PACKAGE_VERSION" "SVN_VERSION""NAVIT_VARIANT; |
72 | int main_argc; |
72 | int main_argc; |
73 | char **main_argv; |
73 | char **main_argv; |
74 | |
74 | |
75 | static void |
75 | static void print_usage(void) |
76 | print_usage(void) |
|
|
77 | { |
76 | { |
78 | 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"); |
77 | 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"); |
79 | } |
78 | } |
80 | |
79 | |
81 | |
|
|
82 | #ifndef USE_PLUGINS |
80 | #ifndef USE_PLUGINS |
83 | extern void builtin_init(void); |
81 | extern void builtin_init(void); |
84 | #endif /* USE_PLUGINS*/ |
82 | #endif /* USE_PLUGINS*/ |
85 | |
83 | |
86 | int main_real(int argc, char **argv) |
84 | int main_real(int argc, char **argv) |
87 | { |
85 | { |
88 | dbg(0,"in main loop 001 ##########################\n"); |
86 | dbg(0, "in main loop 001 ##########################\n"); |
89 | |
87 | |
90 | xmlerror *error = NULL; |
88 | xmlerror *error = NULL; |
91 | char *config_file = NULL; |
89 | char *config_file = NULL; |
92 | int opt; |
90 | int opt; |
93 | char *cp; |
91 | char *cp; |
94 | struct attr navit; |
92 | struct attr navit; |
95 | |
93 | |
96 | GList *list = NULL, *li; |
94 | GList *list = NULL, *li; |
97 | main_argc=argc; |
95 | main_argc = argc; |
98 | main_argv=argv; |
96 | main_argv = argv; |
99 | |
97 | |
100 | dbg(0,"in main loop 002 ##########################\n"); |
98 | //dbg(0, "in main loop 002 ##########################\n"); |
101 | |
99 | |
102 | #ifdef HAVE_GLIB |
100 | #ifdef HAVE_GLIB |
103 | event_glib_init(); |
101 | event_glib_init(); |
104 | dbg(0,"in main loop 003 ##########################\n"); |
102 | //dbg(0,"in main loop 003 ##########################\n"); |
105 | #else |
103 | #else |
106 | _g_slice_thread_init_nomessage(); |
104 | _g_slice_thread_init_nomessage(); |
107 | dbg(0,"in main loop 004 ##########################\n"); |
105 | //dbg(0, "in main loop 004 ##########################\n"); |
108 | #endif |
106 | #endif |
109 | atom_init(); |
107 | atom_init(); |
110 | main_init(argv[0]); |
108 | main_init(argv[0]); |
111 | main_init_nls(); |
109 | main_init_nls(); |
112 | debug_init(argv[0]); |
110 | debug_init(argv[0]); |
… | |
… | |
121 | { |
119 | { |
122 | debug_set_logfile("/Storage Card/navit.log"); |
120 | debug_set_logfile("/Storage Card/navit.log"); |
123 | } |
121 | } |
124 | #endif |
122 | #endif |
125 | |
123 | |
126 | |
|
|
127 | dbg(0,"in main loop 005 ##########################\n"); |
124 | //dbg(0, "in main loop 005 ##########################\n"); |
128 | file_init(); |
125 | file_init(); |
129 | dbg(0,"in main loop 006 ##########################\n"); |
126 | //dbg(0, "in main loop 006 ##########################\n"); |
130 | |
127 | |
131 | #ifndef USE_PLUGINS |
128 | #ifndef USE_PLUGINS |
132 | dbg(0,"in main loop 007 ##########################\n"); |
129 | //dbg(0, "in main loop 007 ##########################\n"); |
133 | builtin_init(); |
130 | builtin_init(); |
134 | #endif |
131 | #endif |
135 | |
132 | |
136 | dbg(0,"in main loop 008 ##########################\n"); |
133 | //dbg(0, "in main loop 008 ##########################\n"); |
137 | route_init(); |
134 | route_init(); |
138 | dbg(0,"in main loop 008.1 ##########################\n"); |
135 | //dbg(0, "in main loop 008.1 ##########################\n"); |
139 | navigation_init(); |
136 | navigation_init(); |
140 | dbg(0,"in main loop 008.2 ##########################\n"); |
137 | //dbg(0, "in main loop 008.2 ##########################\n"); |
141 | tracking_init(); |
138 | tracking_init(); |
142 | dbg(0,"in main loop 008.3 ##########################\n"); |
139 | //dbg(0, "in main loop 008.3 ##########################\n"); |
143 | search_init(); |
140 | search_init(); |
144 | dbg(0,"in main loop 008.4 ##########################\n"); |
141 | //dbg(0, "in main loop 008.4 ##########################\n"); |
145 | linguistics_init(); |
142 | linguistics_init(); |
146 | dbg(0,"in main loop 0014 ##########################\n"); |
143 | //dbg(0, "in main loop 0014 ##########################\n"); |
147 | |
144 | |
148 | config_file=NULL; |
145 | config_file = NULL; |
149 | #ifdef HAVE_GETOPT_H |
146 | #ifdef HAVE_GETOPT_H |
150 | opterr=0; //don't bomb out on errors. |
147 | opterr=0; //don't bomb out on errors. |
151 | #endif /* _MSC_VER */ |
148 | #endif /* _MSC_VER */ |
152 | if (argc > 1) { |
149 | if (argc > 1) |
|
|
150 | { |
153 | /* DEVELOPPERS : don't forget to update the manpage if you modify theses options */ |
151 | /* DEVELOPPERS : don't forget to update the manpage if you modify theses options */ |
154 | while((opt = getopt(argc, argv, ":hvc:d:")) != -1) { |
152 | while ((opt = getopt(argc, argv, ":hvc:d:")) != -1) |
|
|
153 | { |
155 | switch(opt) { |
154 | switch (opt) |
|
|
155 | { |
156 | case 'h': |
156 | case 'h': |
157 | print_usage(); |
157 | print_usage(); |
158 | exit(0); |
158 | exit(0); |
159 | break; |
159 | break; |
160 | case 'v': |
160 | case 'v': |
161 | printf("%s %s\n", "navit", version); |
161 | printf("%s %s\n", "navit", version); |
162 | exit(0); |
162 | exit(0); |
163 | break; |
163 | break; |
164 | case 'c': |
164 | case 'c': |
165 | printf("config file n is set to `%s'\n", optarg); |
165 | printf("config file n is set to `%s'\n", optarg); |
166 | config_file = optarg; |
166 | config_file = optarg; |
167 | break; |
167 | break; |
168 | case 'd': |
168 | case 'd': |
169 | printf("TODO Verbose option is set to `%s'\n", optarg); |
169 | printf("TODO Verbose option is set to `%s'\n", optarg); |
170 | break; |
170 | break; |
171 | #ifdef HAVE_GETOPT_H |
171 | #ifdef HAVE_GETOPT_H |
172 | case ':': |
172 | case ':': |
173 | fprintf(stderr, "navit: Error - Option `%c' needs a value\n", optopt); |
173 | fprintf(stderr, "navit: Error - Option `%c' needs a value\n", optopt); |
174 | print_usage(); |
174 | print_usage(); |
175 | exit(1); |
175 | exit(1); |
176 | break; |
176 | break; |
177 | case '?': |
177 | case '?': |
178 | fprintf(stderr, "navit: Error - No such option: `%c'\n", optopt); |
178 | fprintf(stderr, "navit: Error - No such option: `%c'\n", optopt); |
179 | print_usage(); |
179 | print_usage(); |
180 | exit(1); |
180 | exit(1); |
181 | #endif |
181 | #endif |
182 | } |
182 | } |
183 | } |
183 | } |
184 | // use 1st cmd line option that is left for the config file |
184 | // use 1st cmd line option that is left for the config file |
185 | if (optind < argc) config_file = argv[optind]; |
185 | if (optind < argc) |
|
|
186 | config_file = argv[optind]; |
186 | } |
187 | } |
187 | |
188 | |
188 | // if config file is explicitely given only look for it, otherwise try std paths |
189 | // if config file is explicitely given only look for it, otherwise try std paths |
189 | if (config_file) |
190 | if (config_file) |
190 | { |
191 | { |
191 | list = g_list_append(list,g_strdup(config_file)); |
192 | list = g_list_append(list, g_strdup(config_file)); |
192 | } |
193 | } |
193 | else |
194 | else |
194 | { |
195 | { |
195 | |
196 | |
196 | list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_USER_DATADIR"), "/navit.xml" , NULL)); |
197 | list = g_list_append(list, g_strjoin(NULL, getenv("NAVIT_USER_DATADIR"), "/navit.xml", NULL)); |
197 | list = g_list_append(list,g_strdup("navit.xml")); |
198 | list = g_list_append(list, g_strdup("navit.xml")); |
198 | |
199 | |
199 | #ifdef HAVE_API_ANDROID |
200 | #ifdef HAVE_API_ANDROID |
200 | // **disabled** // new preferred location (the new one should have priority over the legacy!) |
201 | // **disabled** // new preferred location (the new one should have priority over the legacy!) |
201 | // **disabled** // list = g_list_append(list,g_strdup("/sdcard/zanavi/navit.xml")); |
202 | // **disabled** // list = g_list_append(list,g_strdup("/sdcard/zanavi/navit.xml")); |
202 | #endif |
203 | #endif |
203 | |
204 | |
204 | list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml" , NULL)); |
205 | list = g_list_append(list, g_strjoin(NULL, getenv("NAVIT_SHAREDIR"), "/navit.xml", NULL)); |
205 | |
206 | |
206 | #ifndef _WIN32 |
207 | #ifndef _WIN32 |
207 | list = g_list_append(list,g_strdup("/etc/navit/navit.xml")); |
208 | list = g_list_append(list, g_strdup("/etc/navit/navit.xml")); |
208 | #endif |
209 | #endif |
209 | |
210 | |
210 | } |
211 | } |
211 | li = list; |
212 | li = list; |
212 | for (;;) |
213 | for (;;) |
213 | { |
214 | { |
214 | if (li == NULL) |
215 | if (li == NULL) |
215 | { |
216 | { |
216 | // We have not found an existing config file from all possibilities |
217 | // We have not found an existing config file from all possibilities |
217 | dbg(0,"No config file navit.xml, navit.xml.local found\n"); |
218 | dbg(0, "No config file navit.xml, navit.xml.local found\n"); |
218 | return 1; |
219 | return 1; |
219 | } |
220 | } |
220 | // Try the next config file possibility from the list |
221 | // Try the next config file possibility from the list |
221 | config_file = li->data; |
222 | config_file = li->data; |
222 | if (file_exists(config_file)) |
223 | if (file_exists(config_file)) |
223 | { |
224 | { |
224 | break; |
225 | break; |
225 | } |
226 | } |
… | |
… | |
228 | g_free(config_file); |
229 | g_free(config_file); |
229 | } |
230 | } |
230 | li = g_list_next(li); |
231 | li = g_list_next(li); |
231 | } |
232 | } |
232 | |
233 | |
233 | |
|
|
234 | // ############### load XML config file, and call all the init/new functions ################ |
234 | // ############### load XML config file, and call all the init/new functions ################ |
235 | // ############### load XML config file, and call all the init/new functions ################ |
235 | // ############### load XML config file, and call all the init/new functions ################ |
236 | // ############### load XML config file, and call all the init/new functions ################ |
236 | // ############### load XML config file, and call all the init/new functions ################ |
237 | clock_t s_ = debug_measure_start(); |
237 | clock_t s_ = debug_measure_start(); |
238 | if (!config_load(config_file, &error)) |
238 | if (!config_load(config_file, &error)) |
… | |
… | |
250 | li = g_list_next(li); |
250 | li = g_list_next(li); |
251 | } |
251 | } |
252 | |
252 | |
253 | g_list_free(list); |
253 | g_list_free(list); |
254 | |
254 | |
255 | if (! config_get_attr(config, attr_navit, &navit, NULL) && !config_empty_ok) |
255 | if (!config_get_attr(config, attr_navit, &navit, NULL) && !config_empty_ok) |
256 | { |
256 | { |
257 | dbg(0, "No instance has been created, exiting\n"); |
257 | dbg(0, "No instance has been created, exiting\n"); |
258 | exit(1); |
258 | exit(1); |
259 | } |
259 | } |
260 | |
260 | |
261 | dbg(0,"in main loop 026 ##########################\n"); |
261 | dbg(0, "in main loop 026 ##########################\n"); |
262 | event_main_loop_run(); |
262 | event_main_loop_run(); |
263 | dbg(0,"after main loop ##########################"); |
263 | dbg(0, "after main loop ##########################"); |
264 | |
264 | |
265 | #ifndef HAVE_API_ANDROID |
265 | #ifndef HAVE_API_ANDROID |
266 | debug_finished(); |
266 | debug_finished(); |
267 | #endif |
267 | #endif |
268 | return 0; |
268 | return 0; |