]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib:cmdline: Add a --option only parser for testparm
authorAndreas Schneider <asn@samba.org>
Wed, 13 Jan 2021 08:57:19 +0000 (09:57 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 25 May 2021 00:23:37 +0000 (00:23 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/cmdline/cmdline.c
lib/cmdline/cmdline.h

index 15be2e42ff420f19ad9416af5d96552044b7ef34..58e8059b9a88bb10a482a81a4c23ac5e7683e1f8 100644 (file)
@@ -459,6 +459,21 @@ static struct poptOption popt_common_debug[] = {
        POPT_TABLEEND
 };
 
+static struct poptOption popt_common_option[] = {
+       {
+               .argInfo    = POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST,
+               .arg        = (void *)popt_samba_callback,
+       },
+       {
+               .longName   = "option",
+               .argInfo    = POPT_ARG_STRING,
+               .val        = OPT_OPTION,
+               .descrip    = "Set smb.conf option from command line",
+               .argDescrip = "name=value",
+       },
+       POPT_TABLEEND
+};
+
 static struct poptOption popt_common_samba[] = {
        {
                .argInfo    = POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST,
@@ -1218,6 +1233,9 @@ struct poptOption *samba_cmdline_get_popt(enum smb_cmdline_popt_options opt)
        case SAMBA_CMDLINE_POPT_OPT_DEBUG_ONLY:
                return popt_common_debug;
                break;
+       case SAMBA_CMDLINE_POPT_OPT_OPTION_ONLY:
+               return popt_common_option;
+               break;
        case SAMBA_CMDLINE_POPT_OPT_SAMBA:
                return popt_common_samba;
                break;
index 8d8f3ebe5a7e2fa6054766f2698ee2df9e96b8e2..8fe746055c8cce516e59a297812bfee810fd19c9 100644 (file)
@@ -40,6 +40,7 @@ enum samba_cmdline_config_type {
 
 enum smb_cmdline_popt_options {
        SAMBA_CMDLINE_POPT_OPT_DEBUG_ONLY = 1,
+       SAMBA_CMDLINE_POPT_OPT_OPTION_ONLY,
        SAMBA_CMDLINE_POPT_OPT_SAMBA,
        SAMBA_CMDLINE_POPT_OPT_CONNECTION,
        SAMBA_CMDLINE_POPT_OPT_CREDENTIALS,
@@ -153,6 +154,18 @@ poptContext samba_popt_get_context(const char * name,
        .descrip    = "Common debug options:", \
        .argDescrip = NULL },
 
+/**
+ * @brief A popt structure for --option only.
+ */
+#define POPT_COMMON_OPTION_ONLY { \
+       .longName   = NULL, \
+       .shortName  = '\0', \
+       .argInfo    = POPT_ARG_INCLUDE_TABLE, \
+       .arg        = samba_cmdline_get_popt(SAMBA_CMDLINE_POPT_OPT_OPTION_ONLY), \
+       .val        = 0, \
+       .descrip    = "Options:", \
+       .argDescrip = NULL },
+
 /**
  * @brief A popt structure for common samba options.
  */