From f09109c7bc32966bb464df0712583b30602d6ad0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 9 Nov 2002 17:08:58 +0000 Subject: Last sync with HEAD (This used to be commit 1175b62337f5c29954cd5e8dfdc2327c9c80748c) --- source3/smbd/server.c | 132 +++++++++++--------------------------------------- 1 file changed, 27 insertions(+), 105 deletions(-) (limited to 'source3/smbd/server.c') diff --git a/source3/smbd/server.c b/source3/smbd/server.c index ad00794bd7..3d9a4675b2 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -3,6 +3,7 @@ Main SMB server routines Copyright (C) Andrew Tridgell 1992-1998 Copyright (C) Martin Pool 2002 + Copyright (C) Jelmer Vernooij 2002 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 @@ -611,121 +612,49 @@ static void init_structs(void ) } -/**************************************************************************** - Usage on the program. -****************************************************************************/ - -static void usage(char *pname) -{ - - d_printf("Usage: %s [-DaioPh?Vb] [-d debuglevel] [-l log basename] [-p port]\n", pname); - d_printf(" [-O socket options] [-s services file]\n"); - d_printf("\t-D Become a daemon (default)\n"); - d_printf("\t-a Append to log file (default)\n"); - d_printf("\t-i Run interactive (not a daemon)\n" ); - d_printf("\t-o Overwrite log file, don't append\n"); - d_printf("\t-h Print usage\n"); - d_printf("\t-? Print usage\n"); - d_printf("\t-V Print version\n"); - d_printf("\t-b Print build options\n"); - d_printf("\t-d debuglevel Set the debuglevel\n"); - d_printf("\t-l log basename. Basename for log/debug files\n"); - d_printf("\t-p port Listen on the specified port\n"); - d_printf("\t-O socket options Socket options\n"); - d_printf("\t-s services file. Filename of services file\n"); - d_printf("\n"); -} - /**************************************************************************** main program. ****************************************************************************/ - int main(int argc,char *argv[]) + int main(int argc,const char *argv[]) { - extern BOOL append_log; - extern BOOL AllowDebugChange; - extern char *optarg; /* shall I run as a daemon */ - BOOL is_daemon = False; - BOOL interactive = False; - BOOL specified_logfile = False; - char *ports = NULL; + static BOOL is_daemon = False; + static BOOL interactive = False; + static char *ports = NULL; int opt; - pstring logfile; + poptContext pc; + + struct poptOption long_options[] = { + POPT_AUTOHELP + {"daemon", 'D', POPT_ARG_VAL, &is_daemon, True, "Become a daemon (default)" }, + {"interactive", 'i', POPT_ARG_VAL, &interactive, True, "Run interactive (not a daemon)"}, + {"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" }, + {"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"}, + {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug}, + {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile}, + {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_socket_options}, + {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_log_base}, + {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, + { NULL } + }; #ifdef HAVE_SET_AUTH_PARAMETERS set_auth_parameters(argc,argv); #endif - /* this is for people who can't start the program correctly */ - while (argc > 1 && (*argv[1] != '-')) { - argv++; - argc--; - } - - while ( EOF != (opt = getopt(argc, argv, "O:l:s:d:Dp:h?bVaiof:")) ) + pc = poptGetContext("smbd", argc, argv, long_options, 0); + + while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { - case 'O': - pstrcpy(user_socket_options,optarg); - break; - - case 's': - pstrcpy(dyn_CONFIGFILE,optarg); - break; - - case 'l': - specified_logfile = True; - pstr_sprintf(logfile, "%s/log.smbd", optarg); - lp_set_logfile(logfile); - break; - - case 'a': - append_log = True; - break; - - case 'i': - interactive = True; - break; - - case 'o': - append_log = False; - break; - - case 'D': - is_daemon = True; - break; - - case 'd': - if (*optarg == 'A') - DEBUGLEVEL = 10000; - else - DEBUGLEVEL = atoi(optarg); - AllowDebugChange = False; - break; - - case 'p': - ports = optarg; - break; - - case 'h': - case '?': - usage(argv[0]); - exit(0); - break; - - case 'V': - d_printf("Version %s\n",VERSION); - exit(0); - break; case 'b': - build_options(True); /* Display output to screen as well as debug */ + build_options(True); /* Display output to screen as well as debug */ exit(0); break; - default: - DEBUG(0,("Incorrect program usage - are you sure the command line is correct?\n")); - usage(argv[0]); - exit(1); } + } + + poptFreeContext(pc); #ifdef HAVE_SETLUID /* needed for SecureWare on SCO */ @@ -736,13 +665,6 @@ static void usage(char *pname) load_case_tables(); - append_log = True; - - if(!specified_logfile) { - pstr_sprintf(logfile, "%s/log.smbd", dyn_LOGFILEBASE); - lp_set_logfile(logfile); - } - set_remote_machine_name("smbd"); setup_logging(argv[0],interactive); -- cgit