# HG changeset patch # User mas01cr # Date 1193845091 0 # Node ID 5fa52830e532747071252c1cdc1e441aee97d212 # Parent 521cecd1eab72953af56e0a3c511ff9db1adab41 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.. diff -r 521cecd1eab7 -r 5fa52830e532 audioDB.cpp --- 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;