7 /* address canonicalization
9 /* #include <cleanup.h>
11 /* int cleanup_rewrite_external(context_name, result, addr)
12 /* const char *context;
16 /* int cleanup_rewrite_internal(context_name, result, addr)
17 /* const char *context;
21 /* int cleanup_rewrite_tree(context_name, tree)
22 /* const char *context;
25 /* This module rewrites addresses to canonical form, adding missing
26 /* domains and stripping source routes etc., and performs
27 /* \fIcanonical\fR map lookups to map addresses to official form.
28 /* These functions return non-zero when the address was changed.
30 /* cleanup_rewrite_init() performs one-time initialization.
32 /* cleanup_rewrite_external() rewrites the external (quoted) string
33 /* form of an address.
35 /* cleanup_rewrite_internal() is a wrapper around the
36 /* cleanup_rewrite_external() routine that transforms from
37 /* internal (quoted) string form to external form and back.
39 /* cleanup_rewrite_tree() is a wrapper around the
40 /* cleanup_rewrite_external() routine that transforms from
41 /* internal parse tree form to external form and back.
45 /* The name of an address rewriting context that supplies
46 /* the equivalents of myorigin and mydomain.
55 /* The Secure Mailer license must be distributed with this software.
58 /* IBM T.J. Watson Research
60 /* Yorktown Heights, NY 10598, USA
67 /* Utility library. */
75 #include <rewrite_clnt.h>
76 #include <quote_822_local.h>
78 /* Application-specific. */
82 #define STR vstring_str
84 /* cleanup_rewrite_external - rewrite address external form */
86 int cleanup_rewrite_external(const char *context_name
, VSTRING
*result
,
89 rewrite_clnt(context_name
, addr
, result
);
90 return (strcmp(STR(result
), addr
) != 0);
93 /* cleanup_rewrite_tree - rewrite address node */
95 int cleanup_rewrite_tree(const char *context_name
, TOK822
*tree
)
97 VSTRING
*dst
= vstring_alloc(100);
98 VSTRING
*src
= vstring_alloc(100);
101 tok822_externalize(src
, tree
->head
, TOK822_STR_DEFL
);
102 did_rewrite
= cleanup_rewrite_external(context_name
, dst
, STR(src
));
103 tok822_free_tree(tree
->head
);
104 tree
->head
= tok822_scan(STR(dst
), &tree
->tail
);
107 return (did_rewrite
);
110 /* cleanup_rewrite_internal - rewrite address internal form */
112 int cleanup_rewrite_internal(const char *context_name
,
113 VSTRING
*result
, const char *addr
)
115 VSTRING
*dst
= vstring_alloc(100);
116 VSTRING
*src
= vstring_alloc(100);
119 quote_822_local(src
, addr
);
120 did_rewrite
= cleanup_rewrite_external(context_name
, dst
, STR(src
));
121 unquote_822_local(result
, STR(dst
));
124 return (did_rewrite
);