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