From 16c74612b8b1cab6cb0ec279b28b3dd866fb7c91 Mon Sep 17 00:00:00 2001 From: spaetz Date: Tue, 20 May 2008 12:14:44 +0000 Subject: [PATCH] hand the config file to navit with '-c ' rather than just appending to the command line. Bomb out with usage info if someone tries the old way. git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1068 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/main.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/navit/navit/main.c b/navit/navit/main.c index 3445763..2a10d83 100644 --- a/navit/navit/main.c +++ b/navit/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 : set the debug output level to .\n\t-h: print this usage info.\n\t-v: Print the version and exit.\n")); + printf(_("navit usage:\nnavit [options]\n\t-c : use as config file\n\t-d : set the debug output level to . (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); -- 2.7.4