diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2002-11-02 16:16:15 +0000 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2002-11-02 16:16:15 +0000 |
commit | 8a6b05d36d460a1814e72f634835604f48f570d9 (patch) | |
tree | 34b52bbbf4766911503be87a42e6b63062d24f59 /source3/lib | |
parent | a80438d96ce2bc94965b9f26e4976dd5809ae154 (diff) | |
download | samba-8a6b05d36d460a1814e72f634835604f48f570d9.tar.gz samba-8a6b05d36d460a1814e72f634835604f48f570d9.tar.bz2 samba-8a6b05d36d460a1814e72f634835604f48f570d9.zip |
Add more options to popt_common and use them. Current ones are:
-V Version information
-n Set netbios name
-l Set directory to store log files in
-d Set debuglevel
-s Load specified configuration file
-O Set socket options
(This used to be commit 1602d5894947b59fd36c161053a66c0afe2c959c)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/popt_common.c | 59 |
1 files changed, 52 insertions, 7 deletions
diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c index 21ee94d2e6..0fb8874f95 100644 --- a/source3/lib/popt_common.c +++ b/source3/lib/popt_common.c @@ -23,9 +23,12 @@ #include "includes.h" /* Handle command line options: - * -d,--debuglevel - * -s,--configfile - * -O,--socket-options + * d,--debuglevel + * s,--configfile + * O,--socket-options + * V,--version + * l,--log-base + * n,--netbios-name */ extern pstring user_socket_options; @@ -37,6 +40,22 @@ static void popt_common_callback(poptContext con, const struct poptOption *opt, const char *arg, const void *data) { + pstring logfile; + char *pname; + + /* Find out basename of current program */ + pname = strrchr_m(poptGetInvocationName(con),'/'); + + if(!pname)pname = poptGetInvocationName(con); + else pname++; + + if (reason == POPT_CALLBACK_REASON_PRE) { + pstring logfile; + pstr_sprintf(logfile, "%s/log.%s", dyn_LOGFILEBASE, pname); + lp_set_logfile(logfile); + return; + } + switch(opt->val) { case 'd': if (arg) { @@ -51,20 +70,40 @@ static void popt_common_callback(poptContext con, break; case 'O': - pstrcpy(user_socket_options,arg); + if (arg) { + pstrcpy(user_socket_options,arg); + } break; case 's': - pstrcpy(dyn_CONFIGFILE, arg); + if (arg) { + pstrcpy(dyn_CONFIGFILE, arg); + } break; case 'n': - pstrcpy(global_myname,arg); - strupper(global_myname); + if (arg) { + pstrcpy(global_myname,arg); + strupper(global_myname); + } + break; + + case 'l': + if (arg) { + pstr_sprintf(logfile, "%s/log.%s", arg, pname); + lp_set_logfile(logfile); + } break; } } +static void popt_common_init_log(poptContext con, + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, const void *data) +{ +} + struct poptOption popt_common_debug[] = { { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", @@ -95,3 +134,9 @@ struct poptOption popt_common_netbios_name[] = { {"netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name"}, { 0 } }; + +struct poptOption popt_common_log_base[] = { + { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_callback }, + { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files"}, + { 0 } +}; |