diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2003-03-23 13:42:38 +0000 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2003-03-23 13:42:38 +0000 |
commit | dc0ce6f158ec9d9bd74144f78fc0b955bb00a7f1 (patch) | |
tree | 29380bf54ffd9540971b7067181eeb710b95acd9 /source3/nsswitch | |
parent | 8e2c74c6ee50aaf2f51a0456214ae3fc8e0c6613 (diff) | |
download | samba-dc0ce6f158ec9d9bd74144f78fc0b955bb00a7f1.tar.gz samba-dc0ce6f158ec9d9bd74144f78fc0b955bb00a7f1.tar.bz2 samba-dc0ce6f158ec9d9bd74144f78fc0b955bb00a7f1.zip |
Convert to popt.
(This used to be commit 18d52ce914715d188966be95f9e4466666a04f74)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r-- | source3/nsswitch/winbindd.c | 84 |
1 files changed, 26 insertions, 58 deletions
diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index 4033952a6e..c9d6808316 100644 --- a/source3/nsswitch/winbindd.c +++ b/source3/nsswitch/winbindd.c @@ -5,6 +5,7 @@ Copyright (C) by Tim Potter 2000-2002 Copyright (C) Andrew Tridgell 2002 + Copyright (C) Jelmer Vernooij 2003 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 @@ -31,7 +32,6 @@ BOOL opt_dual_daemon = False; static BOOL reload_services_file(BOOL test) { BOOL ret; - pstring logfile; if (lp_loaded()) { pstring fname; @@ -806,27 +806,26 @@ BOOL winbind_setup_common(void) struct winbindd_state server_state; /* Server state information */ - -static void usage(void) -{ - printf("Usage: winbindd [options]\n"); - printf("\t-F daemon in foreground mode\n"); - printf("\t-S log to stdout\n"); - printf("\t-i interactive mode\n"); - printf("\t-B dual daemon mode\n"); - printf("\t-n disable cacheing\n"); - printf("\t-d level set debug level\n"); - printf("\t-s configfile choose smb.conf location\n"); - printf("\t-h show this help message\n"); -} - - int main(int argc, char **argv) +int main(int argc, char **argv) { - extern BOOL AllowDebugChange; pstring logfile; - BOOL interactive = False; - BOOL Fork = True; - BOOL log_stdout = False; + static BOOL interactive = False; + static BOOL Fork = True; + static BOOL log_stdout = False; + struct poptOption long_options[] = { + POPT_AUTOHELP + POPT_COMMON_SAMBA + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, + { "stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" }, + { "foreground", 'F', POPT_ARG_VAL, &Fork, False, "Daemon in foreground mode" }, + { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Interactive mode" }, + { "dual-daemon", 'B', POPT_ARG_VAL, &opt_dual_daemon, True, "Dual daemon mode" }, + { "no-caching", 'n', POPT_ARG_VAL, &opt_nocache, False, "Disable caching" }, + + { 0, 0, 0, 0 } + }; + poptContext pc; int opt; /* glibc (?) likes to print "User defined signal 1" and exit if a @@ -850,56 +849,24 @@ static void usage(void) /* Initialise samba/rpc client stuff */ - while ((opt = getopt(argc, argv, "FSid:s:nhB")) != EOF) { - switch (opt) { + pc = poptGetContext("winbindd", argc, (const char **)argv, long_options, + POPT_CONTEXT_KEEP_FIRST); - case 'F': - Fork = False; - break; - case 'S': - log_stdout = True; - break; + while ((opt = poptGetNextOpt(pc)) != -1) { + switch (opt) { /* Don't become a daemon */ case 'i': interactive = True; log_stdout = True; Fork = False; break; - - /* dual daemon system */ - case 'B': - opt_dual_daemon = True; - break; - - /* disable cacheing */ - case 'n': - opt_nocache = True; - break; - - /* Run with specified debug level */ - case 'd': - DEBUGLEVEL = atoi(optarg); - AllowDebugChange = False; - break; - - /* Load a different smb.conf file */ - case 's': - pstrcpy(dyn_CONFIGFILE,optarg); - break; - - case 'h': - usage(); - exit(0); - - default: - printf("Unknown option %c\n", (char)opt); - exit(1); } } + if (log_stdout && Fork) { printf("Can't log to stdout (-S) unless daemon is in foreground +(-F) or interactive (-i)\n"); - usage(); + poptPrintUsage(pc, stderr, 0); exit(1); } @@ -950,6 +917,7 @@ static void usage(void) DEBUG(0, ("unable to initialise messaging system\n")); exit(1); } + poptFreeContext(pc); register_msg_pool_usage(); message_register(MSG_REQ_TALLOC_USAGE, return_all_talloc_info); |