1/*	$NetBSD$	*/
2
3#ifndef _BOUNCE_TEMPLATE_H_INCLUDED_
4#define _BOUNCE_TEMPLATE_H_INCLUDED_
5
6/*++
7/* NAME
8/*	bounce_template 3h
9/* SUMMARY
10/*	bounce template support
11/* SYNOPSIS
12/*	#include <bounce_template.h>
13/* DESCRIPTION
14/* .nf
15
16 /*
17  * Utility library.
18  */
19#include <vstream.h>
20
21 /*
22  * Structure of a single bounce template. Each template is manipulated by
23  * itself, without any external markers and delimiters. Applications are not
24  * supposed to access BOUNCE_TEMPLATE attributes directly.
25  */
26typedef struct BOUNCE_TEMPLATE {
27    int     flags;
28    const char *class;			/* for diagnostics (fixed) */
29    const char *origin;			/* built-in or pathname */
30    const char *mime_charset;		/* character set (configurable) */
31    const char *mime_encoding;		/* 7bit or 8bit (derived) */
32    const char *from;			/* originator (configurable) */
33    const char *subject;		/* general subject (configurable) */
34    const char *postmaster_subject;	/* postmaster subject (configurable) */
35    const char **message_text;		/* message text (configurable) */
36    const struct BOUNCE_TEMPLATE *prototype;	/* defaults */
37    char   *buffer;			/* ripped text */
38} BOUNCE_TEMPLATE;
39
40#define BOUNCE_TMPL_FLAG_NEW_BUFFER	(1<<0)
41
42#define BOUNCE_TMPL_CLASS_FAILURE	"failure"
43#define BOUNCE_TMPL_CLASS_DELAY		"delay"
44#define BOUNCE_TMPL_CLASS_SUCCESS	"success"
45#define BOUNCE_TMPL_CLASS_VERIFY	"verify"
46
47#define IS_FAILURE_TEMPLATE(t)	((t)->class[0] == BOUNCE_TMPL_CLASS_FAILURE[0])
48#define IS_DELAY_TEMPLATE(t)	((t)->class[0] == BOUNCE_TMPL_CLASS_DELAY[0])
49#define IS_SUCCESS_TEMPLATE(t)	((t)->class[0] == BOUNCE_TMPL_CLASS_SUCCESS[0])
50#define IS_VERIFY_TEMPLATE(t)	((t)->class[0] == BOUNCE_TMPL_CLASS_verify[0])
51
52#define bounce_template_encoding(t)	((t)->mime_encoding)
53#define bounce_template_charset(t)	((t)->mime_charset)
54
55typedef int (*BOUNCE_XP_PRN_FN) (VSTREAM *, const char *, ...);
56typedef int (*BOUNCE_XP_PUT_FN) (VSTREAM *, const char *);
57
58extern BOUNCE_TEMPLATE *bounce_template_create(const BOUNCE_TEMPLATE *);
59extern void bounce_template_free(BOUNCE_TEMPLATE *);
60extern void bounce_template_load(BOUNCE_TEMPLATE *, const char *, const char *);
61extern void bounce_template_headers(BOUNCE_XP_PRN_FN, VSTREAM *, BOUNCE_TEMPLATE *, const char *, int);
62extern void bounce_template_expand(BOUNCE_XP_PUT_FN, VSTREAM *, BOUNCE_TEMPLATE *);
63extern void bounce_template_dump(VSTREAM *, BOUNCE_TEMPLATE *);
64
65#define POSTMASTER_COPY		1	/* postmaster copy */
66#define NO_POSTMASTER_COPY	0	/* not postmaster copy */
67
68 /*
69  * Structure of a bounce template collection. These templates are read and
70  * written in their external representation, with markers and delimiters.
71  */
72typedef struct {
73    BOUNCE_TEMPLATE *failure;
74    BOUNCE_TEMPLATE *delay;
75    BOUNCE_TEMPLATE *success;
76    BOUNCE_TEMPLATE *verify;
77} BOUNCE_TEMPLATES;
78
79BOUNCE_TEMPLATES *bounce_templates_create(void);
80void    bounce_templates_free(BOUNCE_TEMPLATES *);
81void    bounce_templates_load(VSTREAM *, BOUNCE_TEMPLATES *);
82void    bounce_templates_expand(VSTREAM *, BOUNCE_TEMPLATES *);
83void    bounce_templates_dump(VSTREAM *, BOUNCE_TEMPLATES *);
84
85/* LICENSE
86/* .ad
87/* .fi
88/*	The Secure Mailer license must be distributed with this software.
89/* AUTHOR(S)
90/*	Wietse Venema
91/*	IBM T.J. Watson Research
92/*	P.O. Box 704
93/*	Yorktown Heights, NY 10598, USA
94/*--*/
95
96#endif
97