summaryrefslogtreecommitdiff
path: root/navit/main.c
diff options
context:
space:
mode:
authorspaetz <spaetz@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-05-20 12:14:44 +0000
committerspaetz <spaetz@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-05-20 12:14:44 +0000
commit500e3f296c21c271f1d2a44a5b9375bbbbb90985 (patch)
tree4d0e1421c44dfa628a71e1dc5f74670536e695fa /navit/main.c
parent7eafba35934396818bdbab7fead6241909ce7026 (diff)
downloadnavit-500e3f296c21c271f1d2a44a5b9375bbbbb90985.tar.gz
hand the config file to navit with '-c <file>' rather than just appending to the command line. Bomb out with usage info if someone tries the old way.
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1068 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/main.c')
-rw-r--r--navit/main.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/navit/main.c b/navit/main.c
index 34457634a..2a10d8391 100644
--- a/navit/main.c
+++ b/navit/main.c
@@ -115,7 +115,7 @@ main_remove_navit(struct navit *nav)
void
print_usage(void)
{
- printf(_("navit usage:\nnavit [options] [configfile]\n\t-d <n>: set the debug output level to <n>.\n\t-h: print this usage info.\n\t-v: Print the version and exit.\n"));
+ printf(_("navit usage:\nnavit [options]\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"));
}
int main(int argc, char **argv)
@@ -202,7 +202,7 @@ int main(int argc, char **argv)
int opt;
opterr=0; //don't bomb out on errors.
if (argc > 1) {
- while((opt = getopt(argc, argv, ":hvd:")) != -1) {
+ while((opt = getopt(argc, argv, ":hvc:d:")) != -1) {
switch(opt) {
case 'h':
print_usage();
@@ -212,6 +212,10 @@ int main(int argc, char **argv)
printf("%s %s\n", "navit", "0.0.4+svn");
exit(0);
break;
+ case 'c':
+ printf("config file n is set to `%s'\n", optarg);
+ config_file = optarg;
+ break;
case 'd':
printf("TODO Verbose option is set to `%s'\n", optarg);
break;
@@ -227,9 +231,11 @@ int main(int argc, char **argv)
}
}
}
- // the first non-option argument is the config file
- if (optind < argc)
- config_file=argv[optind];
+ if (optind < argc) {
+ // there are still unknown non config options left on the command line.
+ print_usage();
+ exit(1);
+ }
if (! config_file) {
config_file=g_strjoin(NULL,get_home_directory(), "/.navit/navit.xml" , NULL);