File: mailfront.h

package info (click to toggle)
mailfront 2.12-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,072 kB
  • sloc: sh: 5,549; ansic: 5,083; makefile: 35
file content (103 lines) | stat: -rw-r--r-- 3,593 bytes parent folder | download | duplicates (3)
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
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef MAIL_FRONT__MAILFRONT__H__
#define MAIL_FRONT__MAILFRONT__H__

#include "responses.h"
#include <bglibs/iobuf.h>
#include <bglibs/str.h>
#include "constants.h"

#define FLAG_NEED_FILE (1<<0)

#define PLUGIN_VERSION 3

struct command
{
  const char* name;
  int (*fn_enabled)(void);
  int (*fn_noparam)(void);
  int (*fn_hasparam)(str* param);
};

struct plugin
{
  unsigned version;
  struct plugin* next;
  const char* name;
  unsigned flags;
  const struct command* commands;
  const response* (*init)(void);
  const response* (*helo)(str* hostname, str* capabilities);
  const response* (*reset)(void);
  const response* (*sender)(str* address, str* params);
  const response* (*recipient)(str* address, str* params);
  const response* (*data_start)(int fd);
  const response* (*data_block)(const char* bytes, unsigned long len);
  const response* (*message_end)(int fd);
};

#define PROTOCOL_VERSION 3

struct protocol
{
  unsigned version;
  const char* name;
  int (*respond_line)(unsigned number, int final,
		      const char* msg, unsigned long len);
  int (*init)(void);
  int (*mainloop)(const struct command* commands);
};

/* From getprotoenv.c */
extern const char* getprotoenv(const char*);

/* From mailfront.c */
extern const char UNKNOWN[];
extern const response* handle_helo(str* host, str* capabilities);
extern const response* handle_reset(void);
extern const response* handle_sender(str* sender, str* params);
extern const response* handle_recipient(str* recip, str* params);
extern const response* handle_data_start(void);
extern void handle_data_bytes(const char* bytes, unsigned len);
extern const response* handle_message_end(void);
extern int respond(const response*);
extern int respond_line(unsigned number, int final,
			const char* msg, unsigned long len);
extern int respond_multiline(unsigned number, int final, const char* msg);
extern const response* backend_data_block(const char* data, unsigned long len);
extern int scratchfile(void);

/* From modules.c */
extern const response* load_plugin(struct plugin** pptr, const char* name);
extern const response* load_backend(struct plugin** bptr, const char* name);
extern struct plugin* switch_backend(struct plugin* backend);

/* From netstring.c */
int get_netstring_len(ibuf* in, unsigned long* i);
int get_netstring(ibuf* in, str* s);

/* From queuedir.c */
extern void queuedir_init(const char* prefix);
extern const response* queuedir_reset(void);
extern const response* queuedir_sender(str* address, str* params);
extern const response* queuedir_recipient(str* address, str* params);
extern const response* queuedir_data_start(int fd);
extern const response* queuedir_data_block(const char* bytes, unsigned long len);
extern const response* queuedir_message_end(int fd);

/* From session.c */
extern const char* session_protocol(void);
extern const char* session_getenv(const char* name);
extern unsigned long session_getenvu(const char* name);
extern int session_exportenv(void);
extern int session_putenv(const char* s);
extern int session_setenv(const char* name, const char* value, int overwrite);
extern void session_resetenv(void);
extern void session_delnum(const char* name);
extern void session_delstr(const char* name);
extern unsigned long session_getnum(const char* name, unsigned long dflt);
extern int session_hasnum(const char* name, unsigned long* num);
extern const char* session_getstr(const char* name);
extern void session_setnum(const char* name, unsigned long value);
extern void session_setstr(const char* name, const char* value);

#endif /* MAIL_FRONT__MAILFRONT__H__ */