summaryrefslogtreecommitdiffstats
path: root/src/global/tok822.h
blob: 11432965aacf419b76ceaf49af571865ab31e72a (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef _TOK822_H_INCLUDED_
#define _TOK822_H_INCLUDED_

/*++
/* NAME
/*	tok822 3h
/* SUMMARY
/*	RFC822 token structures
/* SYNOPSIS
/*	#include <tok822.h>
/* DESCRIPTION
/* .nf

 /*
  * Utility library.
  */
#include <vstring.h>

 /*
  * Global library.
  */
#include <resolve_clnt.h>

 /*
  * Internal address representation: a token tree.
  */
typedef struct TOK822 {
    int     type;			/* token value, see below */
    VSTRING *vstr;			/* token contents */
    struct TOK822 *prev;		/* peer */
    struct TOK822 *next;		/* peer */
    struct TOK822 *head;		/* group members */
    struct TOK822 *tail;		/* group members */
    struct TOK822 *owner;		/* group owner */
} TOK822;

 /*
  * Token values for multi-character objects. Single-character operators are
  * represented by their own character value.
  */
#define TOK822_MINTOK	256
#define	TOK822_ATOM	256		/* non-special character sequence */
#define	TOK822_QSTRING	257		/* stuff between "", not nesting */
#define	TOK822_COMMENT	258		/* comment including (), may nest */
#define	TOK822_DOMLIT	259		/* stuff between [] not nesting */
#define	TOK822_ADDR	260		/* actually a token group */
#define TOK822_STARTGRP	261		/* start of named group */
#define TOK822_MAXTOK	261

 /*
  * tok822_node.c
  */
extern TOK822 *tok822_alloc(int, const char *);
extern TOK822 *tok822_free(TOK822 *);

 /*
  * tok822_tree.c
  */
extern TOK822 *tok822_append(TOK822 *, TOK822 *);
extern TOK822 *tok822_prepend(TOK822 *, TOK822 *);
extern TOK822 *tok822_cut_before(TOK822 *);
extern TOK822 *tok822_cut_after(TOK822 *);
extern TOK822 *tok822_unlink(TOK822 *);
extern TOK822 *tok822_sub_append(TOK822 *, TOK822 *);
extern TOK822 *tok822_sub_prepend(TOK822 *, TOK822 *);
extern TOK822 *tok822_sub_keep_before(TOK822 *, TOK822 *);
extern TOK822 *tok822_sub_keep_after(TOK822 *, TOK822 *);
extern TOK822 *tok822_free_tree(TOK822 *);

typedef int (*TOK822_ACTION) (TOK822 *);
extern int tok822_apply(TOK822 *, int, TOK822_ACTION);
extern TOK822 **tok822_grep(TOK822 *, int);

 /*
  * tok822_parse.c
  */
extern TOK822 *tok822_scan_limit(const char *, TOK822 **, int);
extern TOK822 *tok822_scan_addr(const char *);
extern TOK822 *tok822_parse_limit(const char *, int);
extern VSTRING *tok822_externalize(VSTRING *, TOK822 *, int);
extern VSTRING *tok822_internalize(VSTRING *, TOK822 *, int);

#define tok822_scan(cp, ptr)	tok822_scan_limit((cp), (ptr), 0)
#define tok822_parse(cp)	tok822_parse_limit((cp), 0)

#define TOK822_STR_NONE	(0)
#define TOK822_STR_WIPE	(1<<0)
#define TOK822_STR_TERM	(1<<1)
#define TOK822_STR_LINE	(1<<2)
#define TOK822_STR_TRNC	(1<<3)
#define TOK822_STR_DEFL	(TOK822_STR_WIPE | TOK822_STR_TERM)
#define TOK822_STR_HEAD	(TOK822_STR_TERM | TOK822_STR_LINE | TOK822_STR_TRNC)

 /*
  * tok822_find.c
  */
extern TOK822 *tok822_find_type(TOK822 *, int);
extern TOK822 *tok822_rfind_type(TOK822 *, int);

 /*
  * tok822_rewrite.c
  */
extern TOK822 *tok822_rewrite(TOK822 *, const char *);

 /*
  * tok822_resolve.c
  */
#define tok822_resolve(t, r) tok822_resolve_from(RESOLVE_NULL_FROM, (t), (r))

extern void tok822_resolve_from(const char *, TOK822 *, RESOLVE_REPLY *);

/* LICENSE
/* .ad
/* .fi
/*	The Secure Mailer license must be distributed with this software.
/* AUTHOR(S)
/*	Wietse Venema
/*	IBM T.J. Watson Research
/*	P.O. Box 704
/*	Yorktown Heights, NY 10598, USA
/*--*/

#endif