mirror of
https://github.com/samba-team/samba.git
synced 2025-12-23 00:23:53 +03:00
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 commit is contained in:
@@ -1697,6 +1697,9 @@ typedef struct {
|
|||||||
extern struct poptOption popt_common_debug[];
|
extern struct poptOption popt_common_debug[];
|
||||||
extern struct poptOption popt_common_configfile[];
|
extern struct poptOption popt_common_configfile[];
|
||||||
extern struct poptOption popt_common_socket_options[];
|
extern struct poptOption popt_common_socket_options[];
|
||||||
|
extern struct poptOption popt_common_version[];
|
||||||
|
extern struct poptOption popt_common_netbios_name[];
|
||||||
|
extern struct poptOption popt_common_log_base[];
|
||||||
|
|
||||||
/* Module support */
|
/* Module support */
|
||||||
typedef NTSTATUS (init_module_function) (void);
|
typedef NTSTATUS (init_module_function) (void);
|
||||||
|
|||||||
@@ -23,9 +23,12 @@
|
|||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
/* Handle command line options:
|
/* Handle command line options:
|
||||||
* -d,--debuglevel
|
* d,--debuglevel
|
||||||
* -s,--configfile
|
* s,--configfile
|
||||||
* -O,--socket-options
|
* O,--socket-options
|
||||||
|
* V,--version
|
||||||
|
* l,--log-base
|
||||||
|
* n,--netbios-name
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern pstring user_socket_options;
|
extern pstring user_socket_options;
|
||||||
@@ -37,6 +40,22 @@ static void popt_common_callback(poptContext con,
|
|||||||
const struct poptOption *opt,
|
const struct poptOption *opt,
|
||||||
const char *arg, const void *data)
|
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) {
|
switch(opt->val) {
|
||||||
case 'd':
|
case 'd':
|
||||||
if (arg) {
|
if (arg) {
|
||||||
@@ -51,20 +70,40 @@ static void popt_common_callback(poptContext con,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'O':
|
case 'O':
|
||||||
|
if (arg) {
|
||||||
pstrcpy(user_socket_options,arg);
|
pstrcpy(user_socket_options,arg);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
|
if (arg) {
|
||||||
pstrcpy(dyn_CONFIGFILE, arg);
|
pstrcpy(dyn_CONFIGFILE, arg);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
|
if (arg) {
|
||||||
pstrcpy(global_myname,arg);
|
pstrcpy(global_myname,arg);
|
||||||
strupper(global_myname);
|
strupper(global_myname);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
if (arg) {
|
||||||
|
pstr_sprintf(logfile, "%s/log.%s", arg, pname);
|
||||||
|
lp_set_logfile(logfile);
|
||||||
|
}
|
||||||
break;
|
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[] = {
|
struct poptOption popt_common_debug[] = {
|
||||||
{ NULL, 0, POPT_ARG_CALLBACK, popt_common_callback },
|
{ NULL, 0, POPT_ARG_CALLBACK, popt_common_callback },
|
||||||
{ "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level",
|
{ "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"},
|
{"netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name"},
|
||||||
{ 0 }
|
{ 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 }
|
||||||
|
};
|
||||||
|
|||||||
@@ -675,15 +675,12 @@ static BOOL init_structs(void)
|
|||||||
{"port", 'p', POPT_ARG_INT, &global_nmb_port, NMB_PORT, "Listen on the specified port" },
|
{"port", 'p', POPT_ARG_INT, &global_nmb_port, NMB_PORT, "Listen on the specified port" },
|
||||||
{NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug },
|
{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_configfile },
|
||||||
/* Various obsolete options */
|
{NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_socket_options },
|
||||||
{NULL, 'N', POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN },
|
{NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version },
|
||||||
{NULL, 'B', POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN },
|
{NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_netbios_name },
|
||||||
{NULL, 'I', POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN },
|
{NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_log_base },
|
||||||
{NULL, 'C', POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN },
|
|
||||||
{NULL, 'G', POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN },
|
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
extern BOOL append_log;
|
|
||||||
int opt;
|
int opt;
|
||||||
pstring logfile;
|
pstring logfile;
|
||||||
|
|
||||||
@@ -719,21 +716,10 @@ static BOOL init_structs(void)
|
|||||||
#if defined(SIGUSR2)
|
#if defined(SIGUSR2)
|
||||||
BlockSignals(True, SIGUSR2);
|
BlockSignals(True, SIGUSR2);
|
||||||
#endif
|
#endif
|
||||||
pc = poptGetContext(argv[0], argc, argv, long_options, 0);
|
pc = poptGetContext("nmbd", argc, argv, long_options, 0);
|
||||||
|
|
||||||
while((opt = poptGetNextOpt(pc)) != -1)
|
while((opt = poptGetNextOpt(pc)) != -1)
|
||||||
{
|
{ }
|
||||||
switch (opt)
|
|
||||||
{
|
|
||||||
case 'N':
|
|
||||||
case 'B':
|
|
||||||
case 'I':
|
|
||||||
case 'C':
|
|
||||||
case 'G':
|
|
||||||
DEBUG(0,("Obsolete option '%c' used\n",opt));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
poptFreeContext(pc);
|
poptFreeContext(pc);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user