]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib:cmdline: Add a debug only option
authorAndreas Schneider <asn@samba.org>
Tue, 5 Jan 2021 13:23:27 +0000 (14:23 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 20 May 2021 02:58:36 +0000 (02:58 +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 e7e65ff13be3ffad79ff19d428cfa004669e87a7..15be2e42ff420f19ad9416af5d96552044b7ef34 100644 (file)
@@ -437,6 +437,28 @@ static void popt_samba_callback(poptContext popt_ctx,
        }
 }
 
+static struct poptOption popt_common_debug[] = {
+       {
+               .argInfo    = POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST,
+               .arg        = (void *)popt_samba_callback,
+       },
+       {
+               .longName   = "debuglevel",
+               .shortName  = 'd',
+               .argInfo    = POPT_ARG_STRING,
+               .val        = 'd',
+               .descrip    = "Set debug level",
+               .argDescrip = "DEBUGLEVEL",
+       },
+       {
+               .longName   = "debug-stdout",
+               .argInfo    = POPT_ARG_NONE,
+               .val        = OPT_DEBUG_STDOUT,
+               .descrip    = "Send debug output to standard output",
+       },
+       POPT_TABLEEND
+};
+
 static struct poptOption popt_common_samba[] = {
        {
                .argInfo    = POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST,
@@ -1193,6 +1215,9 @@ static struct poptOption popt_legacy_s4[] = {
 struct poptOption *samba_cmdline_get_popt(enum smb_cmdline_popt_options opt)
 {
        switch (opt) {
+       case SAMBA_CMDLINE_POPT_OPT_DEBUG_ONLY:
+               return popt_common_debug;
+               break;
        case SAMBA_CMDLINE_POPT_OPT_SAMBA:
                return popt_common_samba;
                break;
index 490d38216d0beec518dfcb83d6d2587ce6dad4bb..14a928d0b5bca8325f53830d858140eda260c298 100644 (file)
@@ -38,7 +38,8 @@ enum samba_cmdline_config_type {
 };
 
 enum smb_cmdline_popt_options {
-       SAMBA_CMDLINE_POPT_OPT_SAMBA = 1,
+       SAMBA_CMDLINE_POPT_OPT_DEBUG_ONLY = 1,
+       SAMBA_CMDLINE_POPT_OPT_SAMBA,
        SAMBA_CMDLINE_POPT_OPT_CONNECTION,
        SAMBA_CMDLINE_POPT_OPT_CREDENTIALS,
        SAMBA_CMDLINE_POPT_OPT_VERSION,
@@ -139,6 +140,18 @@ poptContext samba_popt_get_context(const char * name,
                                   const struct poptOption * options,
                                   unsigned int flags);
 
+/**
+ * @brief A popt structure for common debug options only.
+ */
+#define POPT_COMMON_DEBUG_ONLY { \
+       .longName   = NULL, \
+       .shortName  = '\0', \
+       .argInfo    = POPT_ARG_INCLUDE_TABLE, \
+       .arg        = samba_cmdline_get_popt(SAMBA_CMDLINE_POPT_OPT_DEBUG_ONLY), \
+       .val        = 0, \
+       .descrip    = "Common debug options:", \
+       .argDescrip = NULL },
+
 /**
  * @brief A popt structure for common samba options.
  */