RIP BOOL. Convert BOOL -> bool. I found a few interesting
[samba.git] / source3 / lib / popt_common.c
index 0c0ed86dd1f8d18a5f3261331f0b8ba42107c4eb..ec05762cdf0ffbb6e1c1acd113f51b9967ec3705 100644 (file)
@@ -8,7 +8,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -17,8 +17,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -35,8 +34,8 @@
  */
 
 extern pstring user_socket_options;
-extern BOOL AllowDebugChange;
-extern BOOL override_logfile;
+extern bool AllowDebugChange;
+extern bool override_logfile;
 
 struct user_auth_info cmdline_auth_info;
 
@@ -58,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,
@@ -69,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) {
@@ -78,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':
@@ -134,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" },
@@ -282,7 +290,7 @@ static void get_password_file(struct user_auth_info *a)
 {
        int fd = -1;
        char *p;
-       BOOL close_it = False;
+       bool close_it = False;
        pstring spec;
        char pass[128];