init.o keymap.o mailbox.o main.o menu.o muttlib.o \
mutt_account.o mutt_attach.o mutt_body.o mutt_header.o \
mutt_history.o mutt_logging.o mutt_parse.o mutt_signal.o \
- mutt_socket.o mutt_thread.o mutt_url.o mutt_window.o mx.o \
+ mutt_socket.o mutt_thread.o mutt_url.o mutt_window.o mx.o myvar.o \
pager.o pattern.o postpone.o progress.o query.o recvattach.o \
recvcmd.o resize.o rfc1524.o rfc3676.o safe_asprintf.o \
score.o send.o sendlib.o sidebar.o smtp.o sort.o state.o \
/* this is a lie until mutt_init runs: */
static int MatchesListsize = MAX(NUMVARS, NUMCOMMANDS) + 10;
-/**
- * struct MyVar - A user-set variable
- */
-struct MyVar
-{
- char *name;
- char *value;
- TAILQ_ENTRY(MyVar) entries;
-};
-
-static TAILQ_HEAD(, MyVar) MyVars = TAILQ_HEAD_INITIALIZER(MyVars);
-
#ifdef USE_NOTMUCH
/* List of tags found in last call to mutt_nm_query_complete(). */
static char **nm_tags;
return true;
}
-/**
- * myvar_del - Unset the value of a "my_" variable
- * @param var Variable name
- */
-static void myvar_del(const char *var)
-{
- struct MyVar *myv = NULL;
-
- TAILQ_FOREACH(myv, &MyVars, entries)
- {
- if (mutt_str_strcmp(myv->name, var) == 0)
- {
- TAILQ_REMOVE(&MyVars, myv, entries);
- FREE(&myv->name);
- FREE(&myv->value);
- FREE(&myv);
- return;
- }
- }
-}
-
/**
* parse_attach_list - Parse the "attachments" command
* @param buf Buffer for temporary storage
/* not reached */
}
-/**
- * myvar_get - Get the value of a "my_" variable
- * @param var Variable name
- * @retval ptr Success, value of variable
- * @retval NULL Error, variable doesn't exist
- */
-const char *myvar_get(const char *var)
-{
- struct MyVar *myv = NULL;
-
- TAILQ_FOREACH(myv, &MyVars, entries)
- {
- if (mutt_str_strcmp(myv->name, var) == 0)
- return NONULL(myv->value);
- }
-
- return NULL;
-}
-
-/**
- * myvar_set - Set the value of a "my_" variable
- * @param var Variable name
- * @param val Value to set
- */
-void myvar_set(const char *var, const char *val)
-{
- struct MyVar *myv = NULL;
-
- TAILQ_FOREACH(myv, &MyVars, entries)
- {
- if (mutt_str_strcmp(myv->name, var) == 0)
- {
- mutt_str_replace(&myv->value, val);
- return;
- }
- }
-
- myv = mutt_mem_calloc(1, sizeof(struct MyVar));
- myv->name = mutt_str_strdup(var);
- myv->value = mutt_str_strdup(val);
- TAILQ_INSERT_TAIL(&MyVars, myv, entries);
-}
-
/**
* mutt_command_complete - Complete a command name
* @param buf Buffer for the result
--- /dev/null
+/**
+ * @file
+ * Handling of personal config ('my' variables)
+ *
+ * @authors
+ * Copyright (C) 2018 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include <stddef.h>
+#include "mutt/mutt.h"
+#include "myvar.h"
+
+struct MyVarHead MyVars = TAILQ_HEAD_INITIALIZER(MyVars);
+
+/**
+ * myvar_get - Get the value of a "my_" variable
+ * @param var Variable name
+ * @retval ptr Success, value of variable
+ * @retval NULL Error, variable doesn't exist
+ */
+const char *myvar_get(const char *var)
+{
+ struct MyVar *myv = NULL;
+
+ TAILQ_FOREACH(myv, &MyVars, entries)
+ {
+ if (mutt_str_strcmp(myv->name, var) == 0)
+ return NONULL(myv->value);
+ }
+
+ return NULL;
+}
+
+/**
+ * myvar_set - Set the value of a "my_" variable
+ * @param var Variable name
+ * @param val Value to set
+ */
+void myvar_set(const char *var, const char *val)
+{
+ struct MyVar *myv = NULL;
+
+ TAILQ_FOREACH(myv, &MyVars, entries)
+ {
+ if (mutt_str_strcmp(myv->name, var) == 0)
+ {
+ mutt_str_replace(&myv->value, val);
+ return;
+ }
+ }
+
+ myv = mutt_mem_calloc(1, sizeof(struct MyVar));
+ myv->name = mutt_str_strdup(var);
+ myv->value = mutt_str_strdup(val);
+ TAILQ_INSERT_TAIL(&MyVars, myv, entries);
+}
+
+/**
+ * myvar_del - Unset the value of a "my_" variable
+ * @param var Variable name
+ */
+void myvar_del(const char *var)
+{
+ struct MyVar *myv = NULL;
+
+ TAILQ_FOREACH(myv, &MyVars, entries)
+ {
+ if (mutt_str_strcmp(myv->name, var) == 0)
+ {
+ TAILQ_REMOVE(&MyVars, myv, entries);
+ FREE(&myv->name);
+ FREE(&myv->value);
+ FREE(&myv);
+ return;
+ }
+ }
+}
* Handling of personal config ('my' variables)
*
* @authors
+ * Copyright (C) 2018 Richard Russon <rich@flatcap.org>
+ *
* @copyright
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
#ifndef _MUTT_MYVAR_H
#define _MUTT_MYVAR_H
-#include <stddef.h>
+#include "mutt/mutt.h"
+
+/**
+ * struct MyVar - A user-set variable
+ */
+struct MyVar
+{
+ char *name;
+ char *value;
+ TAILQ_ENTRY(MyVar) entries;
+};
+TAILQ_HEAD(MyVarHead, MyVar);
+
+extern struct MyVarHead MyVars;
+void myvar_del(const char *var);
const char *myvar_get(const char *var);
+void myvar_set(const char *var, const char *val);
#endif /* _MUTT_MYVAR_H */