changeset 151:5fa52830e532

More defensive command-line error checking: * the command line is also used by the WS server, so don't call exit() directly, call error(); * turn the server flag on before parsing the command-line, so that calls to error() do the right thing..
author mas01cr
date Wed, 31 Oct 2007 15:38:11 +0000
parents 521cecd1eab7
children b852e652a9a1
files audioDB.cpp
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/audioDB.cpp	Wed Oct 31 15:24:09 2007 +0000
+++ b/audioDB.cpp	Wed Oct 31 15:38:11 2007 +0000
@@ -42,7 +42,7 @@
     printf("%s\n", gengetopt_args_info_help[1]);
     printf("%s\n", gengetopt_args_info_help[2]);
     printf("%s\n", gengetopt_args_info_help[0]);
-    exit(1);
+    error("No command found");
   }
 
   if(O2_ACTION(COM_SERVER))
@@ -82,8 +82,8 @@
 audioDB::audioDB(const unsigned argc, char* const argv[], adb__queryResponse *adbQueryResponse): O2_AUDIODB_INITIALIZERS
 {
   try {
+    isServer = 1; // FIXME: Hack
     processArgs(argc, argv);
-    isServer = 1; // FIXME: Hack
     assert(O2_ACTION(COM_QUERY));
     query(dbName, inFile, adbQueryResponse);
   } catch(char *err) {
@@ -95,8 +95,8 @@
 audioDB::audioDB(const unsigned argc, char* const argv[], adb__statusResponse *adbStatusResponse): O2_AUDIODB_INITIALIZERS
 {
   try {
+    isServer = 1; // FIXME: Hack
     processArgs(argc, argv);
-    isServer = 1; // FIXME: Hack
     assert(O2_ACTION(COM_STATUS));
     status(dbName, adbStatusResponse);
   } catch(char *err) {
@@ -137,7 +137,7 @@
   }
 
   if (cmdline_parser (argc, argv, &args_info) != 0)
-    exit(1) ;       
+    error("Error parsing command line");
 
   if(args_info.help_given){
     cmdline_parser_print_help();
@@ -175,7 +175,7 @@
     port=args_info.SERVER_arg;
     if(port<100 || port > 100000)
       error("port out of range");
-    isServer=1;
+    isServer = 1;
 #if defined(O2_DEBUG)
     struct sigaction sa;
     sa.sa_sigaction = sigterm_action;