summaryrefslogtreecommitdiffstats
path: root/src/global/mail_stream.h
blob: b5280e4272373af8ca6b1383c18a6e62e6c9aef3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef _MAIL_STREAM_H_INCLUDED_
#define _MAIL_STREAM_H_INCLUDED_

/*++
/* NAME
/*	mail_stream 3h
/* SUMMARY
/*	mail stream management
/* SYNOPSIS
/*	#include <mail_stream.h>
/* DESCRIPTION
/* .nf

 /*
  * System library.
  */
#include <sys/time.h>

 /*
  * Utility library.
  */
#include <vstream.h>
#include <vstring.h>
#include <check_arg.h>

 /*
  * External interface.
  */
typedef struct MAIL_STREAM MAIL_STREAM;

typedef int (*MAIL_STREAM_FINISH_FN) (MAIL_STREAM *, VSTRING *);
typedef int (*MAIL_STREAM_CLOSE_FN) (VSTREAM *);

struct MAIL_STREAM {
    VSTREAM *stream;			/* file or pipe or socket */
    char   *queue;			/* (initial) queue name */
    char   *id;				/* queue id */
    MAIL_STREAM_FINISH_FN finish;	/* finish code */
    MAIL_STREAM_CLOSE_FN close;		/* close stream */
    char   *class;			/* trigger class */
    char   *service;			/* trigger service */
    int     mode;			/* additional permissions */
#ifdef DELAY_ACTION
    int     delay;			/* deferred delivery */
#endif
    struct timeval ctime;		/* creation time */
};

/* Legacy type-unchecked API, internal use. */
#define MAIL_STREAM_CTL_END	0	/* Terminator */
#define MAIL_STREAM_CTL_QUEUE	1	/* Change queue */
#define MAIL_STREAM_CTL_CLASS	2	/* Change notification class */
#define MAIL_STREAM_CTL_SERVICE	3	/* Change notification service */
#define MAIL_STREAM_CTL_MODE	4	/* Change final queue file mode */
#ifdef DELAY_ACTION
#define MAIL_STREAM_CTL_DELAY	5	/* Change final queue file mtime */
#endif

/* Type-checked API, external use. */
#define CA_MAIL_STREAM_CTL_END		MAIL_STREAM_CTL_END
#define CA_MAIL_STREAM_CTL_QUEUE(v)	MAIL_STREAM_CTL_QUEUE, CHECK_CPTR(MAIL_STREAM, char, (v))
#define CA_MAIL_STREAM_CTL_CLASS(v)	MAIL_STREAM_CTL_CLASS, CHECK_CPTR(MAIL_STREAM, char, (v))
#define CA_MAIL_STREAM_CTL_SERVICE(v)	MAIL_STREAM_CTL_SERVICE, CHECK_CPTR(MAIL_STREAM, char, (v))
#define CA_MAIL_STREAM_CTL_MODE(v)	MAIL_STREAM_CTL_MODE, CHECK_VAL(MAIL_STREAM, int, (v))
#ifdef DELAY_ACTION
#define CA_MAIL_STREAM_CTL_DELAY(v)	MAIL_STREAM_CTL_DELAY, CHECK_VAL(MAIL_STREAM, int, (v))
#endif

CHECK_VAL_HELPER_DCL(MAIL_STREAM, int);
CHECK_CPTR_HELPER_DCL(MAIL_STREAM, char);

extern MAIL_STREAM *mail_stream_file(const char *, const char *, const char *, int);
extern MAIL_STREAM *mail_stream_service(const char *, const char *);
extern MAIL_STREAM *mail_stream_command(const char *);
extern void mail_stream_cleanup(MAIL_STREAM *);
extern int mail_stream_finish(MAIL_STREAM *, VSTRING *);
extern void mail_stream_ctl(MAIL_STREAM *, int,...);


/* LICENSE
/* .ad
/* .fi
/*	The Secure Mailer license must be distributed with this software.
/* AUTHOR(S)
/*	Wietse Venema
/*	IBM T.J. Watson Research
/*	P.O. Box 704
/*	Yorktown Heights, NY 10598, USA
/*--*/

#endif