NeoMutt  2024-04-16-36-g75b6fb
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
config_type.c File Reference

Config type representing an email address. More...

#include "config.h"
#include <stddef.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "config_type.h"
#include "address.h"
+ Include dependency graph for config_type.c:

Go to the source code of this file.

Functions

struct Addressaddress_new (const char *addr)
 Create an Address from a string.
 
static void address_destroy (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef)
 Destroy an Address object - Implements ConfigSetType::destroy() -.
 
static int address_string_set (const struct ConfigSet *cs, void *var, struct ConfigDef *cdef, const char *value, struct Buffer *err)
 Set an Address by string - Implements ConfigSetType::string_set() -.
 
static int address_string_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *result)
 Get an Address as a string - Implements ConfigSetType::string_get() -.
 
static struct Addressaddress_dup (struct Address *addr)
 Create a copy of an Address object.
 
static int address_native_set (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
 Set an Address config item by Address object - Implements ConfigSetType::native_set() -.
 
static intptr_t address_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get an Address object from an Address config item - Implements ConfigSetType::native_get() -.
 
static int address_reset (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Reset an Address to its initial value - Implements ConfigSetType::reset() -.
 
const struct Addresscs_subset_address (const struct ConfigSubset *sub, const char *name)
 Get an Address config item by name.
 

Variables

const struct ConfigSetType CstAddress
 Config type representing an Email Address.
 

Detailed Description

Config type representing an email address.

Authors
  • Richard Russon
  • Pietro Cerutti
  • Dennis Schön

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 config_type.c.

Function Documentation

◆ address_new()

struct Address * address_new ( const char *  addr)

Create an Address from a string.

Parameters
addrEmail address to parse
Return values
ptrNew Address object

Definition at line 53 of file config_type.c.

54{
55 struct Address *a = mutt_mem_calloc(1, sizeof(*a));
56 a->mailbox = buf_new(addr);
57 return a;
58}
struct Buffer * buf_new(const char *str)
Allocate a new Buffer.
Definition: buffer.c:303
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
An email address.
Definition: address.h:36
struct Buffer * mailbox
Mailbox and host address.
Definition: address.h:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ address_dup()

static struct Address * address_dup ( struct Address addr)
static

Create a copy of an Address object.

Parameters
addrAddress to duplicate
Return values
ptrNew Address object

Definition at line 165 of file config_type.c.

166{
167 if (!addr)
168 return NULL; /* LCOV_EXCL_LINE */
169
170 struct Address *a = mutt_mem_calloc(1, sizeof(*a));
171 a->personal = buf_dup(addr->personal);
172 a->mailbox = buf_dup(addr->mailbox);
173 return a;
174}
struct Buffer * buf_dup(const struct Buffer *buf)
Copy a Buffer into a new allocated buffer.
Definition: buffer.c:585
struct Buffer * personal
Real name of address.
Definition: address.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_address()

const struct Address * cs_subset_address ( const struct ConfigSubset sub,
const char *  name 
)

Get an Address config item by name.

Parameters
subConfig Subset
nameName of config item
Return values
ptrAddress
NULLEmpty address

Definition at line 273 of file config_type.c.

274{
275 assert(sub && name);
276
277 struct HashElem *he = cs_subset_create_inheritance(sub, name);
278 assert(he);
279
280#ifndef NDEBUG
281 struct HashElem *he_base = cs_get_base(he);
282 assert(DTYPE(he_base->type) == DT_ADDRESS);
283#endif
284
285 intptr_t value = cs_subset_he_native_get(sub, he, NULL);
286 assert(value != INT_MIN);
287
288 return (const struct Address *) value;
289}
struct HashElem * cs_get_base(struct HashElem *he)
Find the root Config Item.
Definition: set.c:160
The item stored in a Hash Table.
Definition: hash.h:43
int type
Type of data stored in Hash Table, e.g. DT_STRING.
Definition: hash.h:44
intptr_t cs_subset_he_native_get(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Natively get the value of a HashElem config item.
Definition: subset.c:258
struct HashElem * cs_subset_create_inheritance(const struct ConfigSubset *sub, const char *name)
Create a Subset config item (inherited)
Definition: subset.c:208
#define DTYPE(t)
Definition: types.h:50
@ DT_ADDRESS
e-mail address
Definition: types.h:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ CstAddress

const struct ConfigSetType CstAddress
Initial value:
= {
"address",
NULL,
NULL,
}
static void address_destroy(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef)
Destroy an Address object - Implements ConfigSetType::destroy() -.
Definition: config_type.c:63
static intptr_t address_native_get(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
Get an Address object from an Address config item - Implements ConfigSetType::native_get() -.
Definition: config_type.c:208
static int address_native_set(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Set an Address config item by Address object - Implements ConfigSetType::native_set() -.
Definition: config_type.c:179
static int address_reset(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
Reset an Address to its initial value - Implements ConfigSetType::reset() -.
Definition: config_type.c:219
static int address_string_get(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *result)
Get an Address as a string - Implements ConfigSetType::string_get() -.
Definition: config_type.c:138
static int address_string_set(const struct ConfigSet *cs, void *var, struct ConfigDef *cdef, const char *value, struct Buffer *err)
Set an Address by string - Implements ConfigSetType::string_set() -.
Definition: config_type.c:75

Config type representing an Email Address.

Definition at line 253 of file config_type.c.