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

Type representing an email address. More...

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

Go to the source code of this file.

Functions

static void address_destroy (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef)
 Destroy an Address object - Implements ConfigSetType::destroy() -. More...
 
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() -. More...
 
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() -. More...
 
static struct Addressaddress_dup (struct Address *addr)
 Create a copy of an Address object. More...
 
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() -. More...
 
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() -. More...
 
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() -. More...
 
struct Addressaddress_new (const char *addr)
 Create an Address from a string. More...
 
void address_free (struct Address **addr)
 Free an Address object. More...
 

Variables

const struct ConfigSetType cst_address
 Config type representing an Email Addresss. More...
 

Detailed Description

Type representing an email address.

Authors
  • Richard Russon
  • Pietro Cerutti

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

Function Documentation

◆ 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 147 of file address.c.

148 {
149  if (!addr)
150  return NULL; /* LCOV_EXCL_LINE */
151 
152  struct Address *a = mutt_mem_calloc(1, sizeof(*a));
153  a->personal = mutt_str_dup(addr->personal);
154  a->mailbox = mutt_str_dup(addr->mailbox);
155  return a;
156 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
An email address.
Definition: address.h:35
char * mailbox
Mailbox and host address.
Definition: address.h:38
char * 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:

◆ 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 237 of file address.c.

238 {
239  struct Address *a = mutt_mem_calloc(1, sizeof(*a));
240  // a->personal = mutt_str_dup(addr);
241  a->mailbox = mutt_str_dup(addr);
242  return a;
243 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
An email address.
Definition: address.h:35
char * 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_free()

void address_free ( struct Address **  addr)

Free an Address object.

Parameters
[out]addrAddress to free

Definition at line 249 of file address.c.

250 {
251  if (!addr || !*addr)
252  return;
253 
254  FREE(&(*addr)->personal);
255  FREE(&(*addr)->mailbox);
256  FREE(addr);
257 }
#define FREE(x)
Definition: memory.h:40
+ Here is the caller graph for this function:

Variable Documentation

◆ cst_address

const struct ConfigSetType cst_address
Initial value:
= {
"address",
NULL,
NULL,
}
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: address.c:161
static void address_destroy(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef)
Destroy an Address object - Implements ConfigSetType::destroy() -.
Definition: address.c:49
#define DT_ADDRESS
e-mail address
Definition: types.h:29
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: address.c:115
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: address.c:201
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: address.c:190
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: address.c:61

Config type representing an Email Addresss.

Definition at line 262 of file address.c.