hand the config file to navit with '-c <file>' rather than just appending to the...
authorspaetz <spaetz@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Tue, 20 May 2008 12:14:44 +0000 (12:14 +0000)
committerspaetz <spaetz@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Tue, 20 May 2008 12:14:44 +0000 (12:14 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@1068 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/main.c

index 3445763..2a10d83 100644 (file)
@@ -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);