break;
case DT_PATH:
FREE((char **) p->var);
- char *init = NULL;
- if (mutt_str_strcmp(p->name, "debug_file") == 0 && debugfile_cmdline)
- init = debugfile_cmdline;
- else
- init = (char *) p->initial;
+ char *init = (char *) p->initial;
if (init)
{
char path[_POSIX_PATH_MAX];
case DT_NUMBER:
case DT_SORT:
case DT_MAGIC:
- if (mutt_str_strcmp(p->name, "debug_level") == 0 && debuglevel_cmdline)
- *((short *) p->var) = debuglevel_cmdline;
- else
- *((short *) p->var) = p->initial;
+ *((short *) p->var) = p->initial;
break;
case DT_REGEX:
{
*
* This method prepares and opens a new debug file for mutt_debug.
*/
-static void start_debug(void)
+void start_debug(void)
{
if (!DebugFile)
return;
snprintf(AttachmentMarker, sizeof(AttachmentMarker), "\033]9;%" PRIu64 "\a",
mutt_rand64());
- /* Start up debugging mode if requested from cmdline */
- if (debuglevel_cmdline > 0)
- {
- debuglevel = debuglevel_cmdline;
- if (debugfile_cmdline)
- {
- DebugFile = mutt_str_strdup(debugfile_cmdline);
- }
- else
- {
- int i = mutt_option_index("debug_file");
- if ((i >= 0) && (MuttVars[i].initial != 0))
- DebugFile = mutt_str_strdup((const char *) MuttVars[i].initial);
- }
- start_debug();
- }
-
/* And about the host... */
/*
return 1;
}
+
+bool set_default_value(const char *name, intptr_t value)
+{
+ if (!name)
+ return false;
+
+ int idx = mutt_option_index(name);
+ if (!idx)
+ return false;
+
+ MuttVars[idx].initial = value;
+ return true;
+}
+
+void reset_value(const char *name)
+{
+ if (!name)
+ return;
+
+ int idx = mutt_option_index(name);
+ if (!idx)
+ return;
+
+ restore_default(&MuttVars[idx]);
+}
#endif
char **envlist = NULL;
+void start_debug(void);
void mutt_exit(int code)
{
char *include_file = NULL;
char *draft_file = NULL;
char *new_magic = NULL;
+ char *dlevel = NULL;
+ char *dfile = NULL;
struct Header *msg = NULL;
struct ListHead attach = STAILQ_HEAD_INITIALIZER(attach);
struct ListHead commands = STAILQ_HEAD_INITIALIZER(commands);
dump_variables = true;
break;
case 'd':
- if (mutt_str_atoi(optarg, &debuglevel_cmdline) < 0 || debuglevel_cmdline <= 0)
- {
- mutt_error(_("Error: value '%s' is invalid for -d."), optarg);
- goto main_exit;
- }
- printf(_("Debugging at level %d.\n"), debuglevel_cmdline);
+ dlevel = optarg;
break;
case 'E':
edit_infile = true;
break;
#ifdef USE_NNTP
case 'g': /* Specify a news server */
- {
- char buf[LONG_STRING];
- snprintf(buf, sizeof(buf), "set news_server=%s", optarg);
- mutt_list_insert_tail(&commands, mutt_str_strdup(buf));
- }
+ set_default_value("news_server", (intptr_t) mutt_str_strdup(optarg));
/* fallthrough */
case 'G': /* List of newsgroups */
flags |= MUTT_SELECT | MUTT_NEWS;
include_file = optarg;
break;
case 'l':
- debugfile_cmdline = optarg;
- printf(_("Debugging at file %s.\n"), debugfile_cmdline);
+ dfile = optarg;
break;
case 'm':
new_magic = optarg;
goto main_exit;
}
+ if (dfile)
+ {
+ set_default_value("debug_file", (intptr_t) mutt_str_strdup(dfile));
+ }
+ reset_value("debug_file");
+
+ if (dlevel)
+ {
+ short num = 0;
+ if ((mutt_str_atos(dlevel, &num) < 0) || (num < 0) || (num > 5))
+ {
+ mutt_error(_("Error: value '%s' is invalid for -d."), dlevel);
+ goto main_exit;
+ }
+ set_default_value("debug_level", (intptr_t) num);
+ }
+ reset_value("debug_level");
+
if (!STAILQ_EMPTY(&cc_list) || !STAILQ_EMPTY(&bcc_list))
{
msg = mutt_new_header();
if (rc != 0)
goto main_curses;
+ /* The command line overrides the config */
+ if (dlevel)
+ reset_value("debug_level");
+ if (dfile)
+ reset_value("debug_file");
+ start_debug();
+
mutt_list_free(&commands);
/* Initialize crypto backends. */
crypt_init();
if (new_magic)
+ {
mx_set_magic(new_magic);
+ set_default_value("mbox_type", (intptr_t) MboxType);
+ }
if (!STAILQ_EMPTY(&queries))
{
bool message_is_tagged(struct Context *ctx, int index);
bool message_is_visible(struct Context *ctx, int index);
+bool set_default_value(const char *name, intptr_t value);
+void reset_value(const char *name);
+
#endif /* _MUTT_PROTOS_H */