xref: /netbsd-src/external/ibm-public/postfix/dist/src/global/mail_stream.h (revision e89934bbf778a6d6d6894877c4da59d0c7835b0f)
1 /*	$NetBSD: mail_stream.h,v 1.2 2017/02/14 01:16:45 christos Exp $	*/
2 
3 #ifndef _MAIL_STREAM_H_INCLUDED_
4 #define _MAIL_STREAM_H_INCLUDED_
5 
6 /*++
7 /* NAME
8 /*	mail_stream 3h
9 /* SUMMARY
10 /*	mail stream management
11 /* SYNOPSIS
12 /*	#include <mail_stream.h>
13 /* DESCRIPTION
14 /* .nf
15 
16  /*
17   * System library.
18   */
19 #include <sys/time.h>
20 
21  /*
22   * Utility library.
23   */
24 #include <vstream.h>
25 #include <vstring.h>
26 #include <check_arg.h>
27 
28  /*
29   * External interface.
30   */
31 typedef struct MAIL_STREAM MAIL_STREAM;
32 
33 typedef int (*MAIL_STREAM_FINISH_FN) (MAIL_STREAM *, VSTRING *);
34 typedef int (*MAIL_STREAM_CLOSE_FN) (VSTREAM *);
35 
36 struct MAIL_STREAM {
37     VSTREAM *stream;			/* file or pipe or socket */
38     char   *queue;			/* (initial) queue name */
39     char   *id;				/* queue id */
40     MAIL_STREAM_FINISH_FN finish;	/* finish code */
41     MAIL_STREAM_CLOSE_FN close;		/* close stream */
42     char   *class;			/* trigger class */
43     char   *service;			/* trigger service */
44     int     mode;			/* additional permissions */
45 #ifdef DELAY_ACTION
46     int     delay;			/* deferred delivery */
47 #endif
48     struct timeval ctime;		/* creation time */
49 };
50 
51 /* Legacy type-unchecked API, internal use. */
52 #define MAIL_STREAM_CTL_END	0	/* Terminator */
53 #define MAIL_STREAM_CTL_QUEUE	1	/* Change queue */
54 #define MAIL_STREAM_CTL_CLASS	2	/* Change notification class */
55 #define MAIL_STREAM_CTL_SERVICE	3	/* Change notification service */
56 #define MAIL_STREAM_CTL_MODE	4	/* Change final queue file mode */
57 #ifdef DELAY_ACTION
58 #define MAIL_STREAM_CTL_DELAY	5	/* Change final queue file mtime */
59 #endif
60 
61 /* Type-checked API, external use. */
62 #define CA_MAIL_STREAM_CTL_END		MAIL_STREAM_CTL_END
63 #define CA_MAIL_STREAM_CTL_QUEUE(v)	MAIL_STREAM_CTL_QUEUE, CHECK_CPTR(MAIL_STREAM, char, (v))
64 #define CA_MAIL_STREAM_CTL_CLASS(v)	MAIL_STREAM_CTL_CLASS, CHECK_CPTR(MAIL_STREAM, char, (v))
65 #define CA_MAIL_STREAM_CTL_SERVICE(v)	MAIL_STREAM_CTL_SERVICE, CHECK_CPTR(MAIL_STREAM, char, (v))
66 #define CA_MAIL_STREAM_CTL_MODE(v)	MAIL_STREAM_CTL_MODE, CHECK_VAL(MAIL_STREAM, int, (v))
67 #ifdef DELAY_ACTION
68 #define CA_MAIL_STREAM_CTL_DELAY(v)	MAIL_STREAM_CTL_DELAY, CHECK_VAL(MAIL_STREAM, int, (v))
69 #endif
70 
71 CHECK_VAL_HELPER_DCL(MAIL_STREAM, int);
72 CHECK_CPTR_HELPER_DCL(MAIL_STREAM, char);
73 
74 extern MAIL_STREAM *mail_stream_file(const char *, const char *, const char *, int);
75 extern MAIL_STREAM *mail_stream_service(const char *, const char *);
76 extern MAIL_STREAM *mail_stream_command(const char *);
77 extern void mail_stream_cleanup(MAIL_STREAM *);
78 extern int mail_stream_finish(MAIL_STREAM *, VSTRING *);
79 extern void mail_stream_ctl(MAIL_STREAM *, int,...);
80 
81 
82 /* LICENSE
83 /* .ad
84 /* .fi
85 /*	The Secure Mailer license must be distributed with this software.
86 /* AUTHOR(S)
87 /*	Wietse Venema
88 /*	IBM T.J. Watson Research
89 /*	P.O. Box 704
90 /*	Yorktown Heights, NY 10598, USA
91 /*--*/
92 
93 #endif
94