1 /*	$NetBSD: tok822.h,v 1.1.1.1 2009/06/23 10:08:48 tron Exp $	*/
2 
3 #ifndef _TOK822_H_INCLUDED_
4 #define _TOK822_H_INCLUDED_
5 
6 /*++
7 /* NAME
8 /*	tok822 3h
9 /* SUMMARY
10 /*	RFC822 token structures
11 /* SYNOPSIS
12 /*	#include <tok822.h>
13 /* DESCRIPTION
14 /* .nf
15 
16  /*
17   * Utility library.
18   */
19 #include <vstring.h>
20 
21  /*
22   * Global library.
23   */
24 #include <resolve_clnt.h>
25 
26  /*
27   * Internal address representation: a token tree.
28   */
29 typedef struct TOK822 {
30     int     type;			/* token value, see below */
31     VSTRING *vstr;			/* token contents */
32     struct TOK822 *prev;		/* peer */
33     struct TOK822 *next;		/* peer */
34     struct TOK822 *head;		/* group members */
35     struct TOK822 *tail;		/* group members */
36     struct TOK822 *owner;		/* group owner */
37 } TOK822;
38 
39  /*
40   * Token values for multi-character objects. Single-character operators are
41   * represented by their own character value.
42   */
43 #define TOK822_MINTOK	256
44 #define	TOK822_ATOM	256		/* non-special character sequence */
45 #define	TOK822_QSTRING	257		/* stuff between "", not nesting */
46 #define	TOK822_COMMENT	258		/* comment including (), may nest */
47 #define	TOK822_DOMLIT	259		/* stuff between [] not nesting */
48 #define	TOK822_ADDR	260		/* actually a token group */
49 #define TOK822_STARTGRP	261		/* start of named group */
50 #define TOK822_MAXTOK	261
51 
52  /*
53   * tok822_node.c
54   */
55 extern TOK822 *tok822_alloc(int, const char *);
56 extern TOK822 *tok822_free(TOK822 *);
57 
58  /*
59   * tok822_tree.c
60   */
61 extern TOK822 *tok822_append(TOK822 *, TOK822 *);
62 extern TOK822 *tok822_prepend(TOK822 *, TOK822 *);
63 extern TOK822 *tok822_cut_before(TOK822 *);
64 extern TOK822 *tok822_cut_after(TOK822 *);
65 extern TOK822 *tok822_unlink(TOK822 *);
66 extern TOK822 *tok822_sub_append(TOK822 *, TOK822 *);
67 extern TOK822 *tok822_sub_prepend(TOK822 *, TOK822 *);
68 extern TOK822 *tok822_sub_keep_before(TOK822 *, TOK822 *);
69 extern TOK822 *tok822_sub_keep_after(TOK822 *, TOK822 *);
70 extern TOK822 *tok822_free_tree(TOK822 *);
71 
72 typedef int (*TOK822_ACTION) (TOK822 *);
73 extern int tok822_apply(TOK822 *, int, TOK822_ACTION);
74 extern TOK822 **tok822_grep(TOK822 *, int);
75 
76  /*
77   * tok822_parse.c
78   */
79 extern TOK822 *tok822_scan_limit(const char *, TOK822 **, int);
80 extern TOK822 *tok822_scan_addr(const char *);
81 extern TOK822 *tok822_parse_limit(const char *, int);
82 extern VSTRING *tok822_externalize(VSTRING *, TOK822 *, int);
83 extern VSTRING *tok822_internalize(VSTRING *, TOK822 *, int);
84 
85 #define tok822_scan(cp, ptr)	tok822_scan_limit((cp), (ptr), 0)
86 #define tok822_parse(cp)	tok822_parse_limit((cp), 0)
87 
88 #define TOK822_STR_NONE	(0)
89 #define TOK822_STR_WIPE	(1<<0)
90 #define TOK822_STR_TERM	(1<<1)
91 #define TOK822_STR_LINE	(1<<2)
92 #define TOK822_STR_TRNC	(1<<3)
93 #define TOK822_STR_DEFL	(TOK822_STR_WIPE | TOK822_STR_TERM)
94 #define TOK822_STR_HEAD	(TOK822_STR_TERM | TOK822_STR_LINE | TOK822_STR_TRNC)
95 
96  /*
97   * tok822_find.c
98   */
99 extern TOK822 *tok822_find_type(TOK822 *, int);
100 extern TOK822 *tok822_rfind_type(TOK822 *, int);
101 
102  /*
103   * tok822_rewrite.c
104   */
105 extern TOK822 *tok822_rewrite(TOK822 *, const char *);
106 
107  /*
108   * tok822_resolve.c
109   */
110 #define tok822_resolve(t, r) tok822_resolve_from(RESOLVE_NULL_FROM, (t), (r))
111 
112 extern void tok822_resolve_from(const char *, TOK822 *, RESOLVE_REPLY *);
113 
114 /* LICENSE
115 /* .ad
116 /* .fi
117 /*	The Secure Mailer license must be distributed with this software.
118 /* AUTHOR(S)
119 /*	Wietse Venema
120 /*	IBM T.J. Watson Research
121 /*	P.O. Box 704
122 /*	Yorktown Heights, NY 10598, USA
123 /*--*/
124 
125 #endif
126