summaryrefslogtreecommitdiffstats
path: root/pigeonhole/src/lib-sieve/sieve-address.h
blob: 3779a07ced3031caad612a376051f0559dc6b451 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef SIEVE_ADDRESS_H
#define SIEVE_ADDRESS_H

#include "lib.h"
#include "strfuncs.h"
#include "smtp-address.h"

#include "sieve-common.h"
#include "sieve-stringlist.h"

/*
 * Address list API
 */

struct sieve_address_list {
	struct sieve_stringlist strlist;

	int (*next_item)(struct sieve_address_list *_addrlist,
			 struct smtp_address *addr_r, string_t **unparsed_r);
};

static inline int
sieve_address_list_next_item(struct sieve_address_list *addrlist,
			     struct smtp_address *addr_r, string_t **unparsed_r)
{
	return addrlist->next_item(addrlist, addr_r, unparsed_r);
}

static inline void
sieve_address_list_reset(struct sieve_address_list *addrlist)
{
	sieve_stringlist_reset(&addrlist->strlist);
}

static inline int
sieve_address_list_get_length(struct sieve_address_list *addrlist)
{
	return sieve_stringlist_get_length(&addrlist->strlist);
}

static inline void
sieve_address_list_set_trace(struct sieve_address_list *addrlist, bool trace)
{
	sieve_stringlist_set_trace(&addrlist->strlist, trace);
}

/*
 * Header address list
 */

struct sieve_address_list *
sieve_header_address_list_create(const struct sieve_runtime_env *renv,
				 struct sieve_stringlist *field_values);

/*
 * Sieve address parsing/validatin
 */

const struct smtp_address *
sieve_address_parse(const char *address, const char **error_r);
const struct smtp_address *
sieve_address_parse_str(string_t *address, const char **error_r);

bool sieve_address_validate(const char *address, const char **error_r);
bool sieve_address_validate_str(string_t *address, const char **error_r);

#endif