NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
myvar.h File Reference

Handling of personal config ('my' variables) More...

#include "mutt/lib.h"
+ Include dependency graph for myvar.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  MyVar
 A user-set variable. More...
 

Functions

 TAILQ_HEAD (MyVarList, MyVar)
 
void myvar_del (const char *var)
 Unset the value of a "my_" variable. More...
 
const char * myvar_get (const char *var)
 Get the value of a "my_" variable. More...
 
void myvar_set (const char *var, const char *val)
 Set the value of a "my_" variable. More...
 
void myvar_append (const char *var, const char *val)
 Append to the value of a "my_" variable. More...
 
void myvarlist_free (struct MyVarList *list)
 Free a List of MyVars. More...
 

Variables

struct MyVarList MyVars
 List of all the user's custom config variables. More...
 

Detailed Description

Handling of personal config ('my' variables)

Authors
  • Richard Russon

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/.

Definition in file myvar.h.

Function Documentation

◆ TAILQ_HEAD()

TAILQ_HEAD ( MyVarList  ,
MyVar   
)

◆ myvar_del()

void myvar_del ( const char *  var)

Unset the value of a "my_" variable.

Parameters
varVariable name

Definition at line 146 of file myvar.c.

147 {
148  struct MyVar *myv = myvar_find(var);
149 
150  if (myv)
151  {
152  TAILQ_REMOVE(&MyVars, myv, entries);
153  myvar_free(&myv);
154  }
155 }
static void myvar_free(struct MyVar **ptr)
Free a MyVar.
Definition: myvar.c:56
static struct MyVar * myvar_find(const char *var)
Locate a "my_" variable.
Definition: myvar.c:73
A user-set variable.
Definition: myvar.h:31
struct MyVarList MyVars
List of all the user's custom config variables.
Definition: myvar.c:34
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:841
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ myvar_get()

const char* myvar_get ( const char *  var)

Get the value of a "my_" variable.

Parameters
varVariable name
Return values
ptrSuccess, value of variable
NULLError, variable doesn't exist

Definition at line 92 of file myvar.c.

93 {
94  struct MyVar *myv = myvar_find(var);
95 
96  if (myv)
97  {
98  return NONULL(myv->value);
99  }
100 
101  return NULL;
102 }
#define NONULL(x)
Definition: string2.h:37
static struct MyVar * myvar_find(const char *var)
Locate a "my_" variable.
Definition: myvar.c:73
A user-set variable.
Definition: myvar.h:31
char * value
Value of user variable.
Definition: myvar.h:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ myvar_set()

void myvar_set ( const char *  var,
const char *  val 
)

Set the value of a "my_" variable.

Parameters
varVariable name
valValue to set

Definition at line 109 of file myvar.c.

110 {
111  struct MyVar *myv = myvar_find(var);
112 
113  if (myv)
114  {
115  mutt_str_replace(&myv->value, val);
116  return;
117  }
118 
119  myv = myvar_new(var, val);
120  TAILQ_INSERT_TAIL(&MyVars, myv, entries);
121 }
static struct MyVar * myvar_new(const char *name, const char *value)
Create a new MyVar.
Definition: myvar.c:44
static struct MyVar * myvar_find(const char *var)
Locate a "my_" variable.
Definition: myvar.c:73
A user-set variable.
Definition: myvar.h:31
struct MyVarList MyVars
List of all the user's custom config variables.
Definition: myvar.c:34
char * value
Value of user variable.
Definition: myvar.h:34
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:809
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ myvar_append()

void myvar_append ( const char *  var,
const char *  val 
)

Append to the value of a "my_" variable.

Parameters
varVariable name
valValue to append

Definition at line 128 of file myvar.c.

129 {
130  struct MyVar *myv = myvar_find(var);
131 
132  if (myv)
133  {
134  mutt_str_append_item(&myv->value, val, '\0');
135  return;
136  }
137 
138  myv = myvar_new(var, val);
139  TAILQ_INSERT_TAIL(&MyVars, myv, entries);
140 }
static struct MyVar * myvar_new(const char *name, const char *value)
Create a new MyVar.
Definition: myvar.c:44
static struct MyVar * myvar_find(const char *var)
Locate a "my_" variable.
Definition: myvar.c:73
A user-set variable.
Definition: myvar.h:31
struct MyVarList MyVars
List of all the user's custom config variables.
Definition: myvar.c:34
char * value
Value of user variable.
Definition: myvar.h:34
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:809
void mutt_str_append_item(char **str, const char *item, char sep)
Add string to another separated by sep.
Definition: string.c:466
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ myvarlist_free()

void myvarlist_free ( struct MyVarList *  list)

Free a List of MyVars.

Parameters
listList of MyVars

Definition at line 161 of file myvar.c.

162 {
163  if (!list)
164  return;
165 
166  struct MyVar *myv = NULL;
167  struct MyVar *tmp = NULL;
168  TAILQ_FOREACH_SAFE(myv, list, entries, tmp)
169  {
170  TAILQ_REMOVE(list, myv, entries);
171  myvar_free(&myv);
172  }
173 }
static void myvar_free(struct MyVar **ptr)
Free a MyVar.
Definition: myvar.c:56
#define TAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:735
A user-set variable.
Definition: myvar.h:31
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:841
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ MyVars

struct MyVarList MyVars

List of all the user's custom config variables.

Definition at line 34 of file myvar.c.