1 /*	$NetBSD: bounce_template.h,v 1.3 2022/10/08 16:12:45 christos Exp $	*/
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   */
26 typedef 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 *obs_from;		/* originator (configurable) */
33     const char *std_from;		/* originator (configurable) */
34     const char *subject;		/* general subject (configurable) */
35     const char *postmaster_subject;	/* postmaster subject (configurable) */
36     const char **message_text;		/* message text (configurable) */
37     const struct BOUNCE_TEMPLATE *prototype;	/* defaults */
38     char   *buffer;			/* ripped text */
39 } BOUNCE_TEMPLATE;
40 
41 #define BOUNCE_TMPL_FLAG_NEW_BUFFER	(1<<0)
42 
43 #define BOUNCE_TMPL_CLASS_FAILURE	"failure"
44 #define BOUNCE_TMPL_CLASS_DELAY		"delay"
45 #define BOUNCE_TMPL_CLASS_SUCCESS	"success"
46 #define BOUNCE_TMPL_CLASS_VERIFY	"verify"
47 
48 #define IS_FAILURE_TEMPLATE(t)	((t)->class[0] == BOUNCE_TMPL_CLASS_FAILURE[0])
49 #define IS_DELAY_TEMPLATE(t)	((t)->class[0] == BOUNCE_TMPL_CLASS_DELAY[0])
50 #define IS_SUCCESS_TEMPLATE(t)	((t)->class[0] == BOUNCE_TMPL_CLASS_SUCCESS[0])
51 
52 #define bounce_template_encoding(t)	((t)->mime_encoding)
53 #define bounce_template_charset(t)	((t)->mime_charset)
54 
55 typedef int PRINTFPTRLIKE(2, 3) (*BOUNCE_XP_PRN_FN) (VSTREAM *, const char *,...);
56 typedef int (*BOUNCE_XP_PUT_FN) (VSTREAM *, const char *);
57 
58 extern BOUNCE_TEMPLATE *bounce_template_create(const BOUNCE_TEMPLATE *);
59 extern void bounce_template_free(BOUNCE_TEMPLATE *);
60 extern void bounce_template_load(BOUNCE_TEMPLATE *, const char *, const char *);
61 extern void bounce_template_headers(BOUNCE_XP_PRN_FN, VSTREAM *, BOUNCE_TEMPLATE *, const char *, int);
62 extern void bounce_template_expand(BOUNCE_XP_PUT_FN, VSTREAM *, BOUNCE_TEMPLATE *);
63 extern 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   */
72 typedef struct {
73     BOUNCE_TEMPLATE *failure;
74     BOUNCE_TEMPLATE *delay;
75     BOUNCE_TEMPLATE *success;
76     BOUNCE_TEMPLATE *verify;
77 } BOUNCE_TEMPLATES;
78 
79 BOUNCE_TEMPLATES *bounce_templates_create(void);
80 void    bounce_templates_free(BOUNCE_TEMPLATES *);
81 void    bounce_templates_load(VSTREAM *, BOUNCE_TEMPLATES *);
82 void    bounce_templates_expand(VSTREAM *, BOUNCE_TEMPLATES *);
83 void    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 /*	Wietse Venema
96 /*	Google, Inc.
97 /*	111 8th Avenue
98 /*	New York, NY 10011, USA
99 /*--*/
100 
101 #endif
102