From faab8dba02d364dccf341e0f6756b1bf625d3c5b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 22 Aug 2007 11:55:48 +0000 Subject: r24618: move printing out the version string and exit() into the popt _POST processing. Now 'smbd -V --bla' complains about an unknown option metze (This used to be commit c115de4beac887442a73b4a85367d7b5fded68e6) --- source3/lib/popt_common.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c index efffd3c11b..3be25b4363 100644 --- a/source3/lib/popt_common.c +++ b/source3/lib/popt_common.c @@ -57,6 +57,8 @@ static void set_logfile(poptContext con, const char * arg) lp_set_logfile(logfile); } +static BOOL PrintSambaVersionString; + static void popt_common_callback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, @@ -68,6 +70,14 @@ static void popt_common_callback(poptContext con, return; } + if (reason == POPT_CALLBACK_REASON_POST) { + if (!PrintSambaVersionString) return; + + printf( "Version %s\n", SAMBA_VERSION_STRING); + exit(0); + return; + } + switch(opt->val) { case 'd': if (arg) { @@ -77,8 +87,7 @@ static void popt_common_callback(poptContext con, break; case 'V': - printf( "Version %s\n", SAMBA_VERSION_STRING); - exit(0); + PrintSambaVersionString = True; break; case 'O': @@ -133,7 +142,7 @@ struct poptOption popt_common_connection[] = { }; struct poptOption popt_common_samba[] = { - { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, (void *)popt_common_callback }, + { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, (void *)popt_common_callback }, { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternate configuration file", "CONFIGFILE" }, { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Base name for log files", "LOGFILEBASE" }, -- cgit