File: pfqlib.h

package info (click to toggle)
pfqueue 0.5.3-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,400 kB
  • ctags: 595
  • sloc: sh: 8,964; ansic: 3,904; makefile: 80
file content (215 lines) | stat: -rw-r--r-- 5,575 bytes parent folder | download
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215

/*
 * pfqueue library interface
 */

#ifndef __PFQLIB_H
#define __PFQLIB_H

#include <time.h>
#include <regex.h>
#include <sys/types.h>
#include "pfregex.h"

#ifdef __cplusplus
extern "C" {
#endif

#define PFQL_VERSION "1.2"

struct pfql_conf_t {
	int   max_char;			/* Max char buffer length */
	short initial_queue;		/* Queue to start with */
	char  backends_path[200];	/* Path to backends */
	char  backend_name[200];	/* Backend to use */
	char  backend_config[200];	/* Backend configuration path */
	char  backend_progs[200];	/* Backend bin bath */
	int   msg_max;			/* Maximum number of messages */
	int   scan_limit;		/* Max secs for a single scan */
	int   scan_delay;		/* Secs between scans */
	char  remote_host[200];		/* Remote host (for socket backend only) */
	int   remote_port;		/* Remote port (for socket backend only) */
};

struct pfql_status_t {
	short auto_wrk_tagged;
	short wrk_tagged;
	short ask_confirm;
	short do_scan;
	short use_envelope;
	short use_colors;
	short cur_queue;
};

struct pfql_context_t {
	struct msg_t *queue;
	struct be_msg_t *queue_thread;
	struct pfql_status_t pfql_status;
	struct pfql_conf_t   pfql_conf;
	
	int dig_lastqueue;
	time_t queue_last_changed;
	int NUMMSG;
	int NUMTAG;

	int thread_control;
	void *beptr;
	char* (*pfqbe_id)();
	char* (*pfqbe_version)();
	int (*pfqbe_apiversion)();
	int (*pfqbe_init)();
	int (*pfqbe_setup)(struct msg_t*,struct be_msg_t*);
	int (*pfqbe_close)();
	int (*pfqbe_fill_queue)();
	int (*pfqbe_retr_headers)(const char*);
	int (*pfqbe_retr_status)(const char*);
	int (*pfqbe_retr_body)(const char*,char*,size_t);
	int (*pfqbe_message_delete)(const char*);
	int (*pfqbe_message_hold)(const char*);
	int (*pfqbe_message_release)(const char*);
	int (*pfqbe_message_requeue)(const char*);
	int (*pfqbe_set_queue)(int);
	char* (*pfqbe_queue_name)(int);
	void (*pfqbe_use_envelope)(int);
	int (*pfqbe_get_caps)();
	int (*pfqbe_queue_count)();
	struct pfb_conf_t* (*pfqbe_getconf)();

	regex_t  *regexp;
	int search_mode;
};

/* -----------------
 * Library functions
 * ----------------- */

// Initializes library
int		pfql_init(struct pfql_context_t *);

// Create context
int		pfql_context_create ( struct pfql_context_t **);

// Destroy context
int		pfql_context_destroy ( struct pfql_context_t *);

// Start using library
int		pfql_start(struct pfql_context_t *);

// Returns library version
const char*	pfql_version();

// Returns status
struct pfql_status_t *pfql_getstatus(struct pfql_context_t *);

// Returns current configuration
struct pfql_conf_t   *pfql_getconf(struct pfql_context_t *);

/*
 * Backend functions
 */

// Returns backend API version
int	 	pfql_backend_apiversion(struct pfql_context_t *);

// Returns backend identifier
const char*	pfql_backend_id(struct pfql_context_t *);

// Returns backend version
const char*	pfql_backend_version(struct pfql_context_t *);

// Sets backend configuration path/file
void		pfql_backend_setconfig(struct pfql_context_t *,const char*);

// Sets backend MTA command
void		pfql_backend_setcommand(struct pfql_context_t *,const char*);

// Sets MTA version
void		pfql_backend_setversion(struct pfql_context_t *,const char*);

// Number of queues
int		pfql_num_queues(struct pfql_context_t *);

// Returns queue name
const char* 	pfql_queue_name(struct pfql_context_t *,int);

// Sets current queue
void		pfql_set_queue(struct pfql_context_t *,int);

// The last time the queue changed
time_t		pfql_queue_last_changed(struct pfql_context_t *);

// Retreive message status
int 		pfql_retr_status(struct pfql_context_t *,const char*);

// Retreive message headers
int		pfql_retr_headers(struct pfql_context_t *,const char*);

// Retreive message body
int		pfql_retr_body(struct pfql_context_t *,const char*, void*, size_t);

// Returns the number of messages in the queue
int		pfql_num_msg(struct pfql_context_t *);

// Returns the number of tagged messages
int		pfql_num_tag(struct pfql_context_t *);

// Tags all messages
void		pfql_tag_all(struct pfql_context_t *);

// Untag all messages
void		pfql_tag_none(struct pfql_context_t *);

// Tags a single message
void		pfql_msg_tag(struct pfql_context_t *,const char*);

// Untags a single message
void		pfql_msg_untag(struct pfql_context_t *,const char*);

// Toggle tag flag on message
void		pfql_msg_toggletag(struct pfql_context_t *,const char*);

// Returns wether the message is tagged or not
int		pfql_msg_istagged(struct pfql_context_t *,const char*);

// Performs an action on the message
void		pfql_msg_action(struct pfql_context_t *,const char*,int);

// Toggle reading from envelope, if the backend supports it
void		pfql_toggle_envelope(struct pfql_context_t *);

// Search for a regexp (first occurence)
int		pfql_msg_search(struct pfql_context_t *,const char*);

// Search message forward
int		pfql_msg_searchnext(struct pfql_context_t *,const char*);

// Search message backward
int		pfql_msg_searchprev(struct pfql_context_t *,const char*);

// Search next message and tag it
void		pfql_msg_searchandtag(struct pfql_context_t *,const char*);

// Returns message at a given position in the queue
struct msg_t*	pfql_msg_at(struct pfql_context_t *,int);

// Returns message position
struct msg_t*	pfql_msg(struct pfql_context_t *,const char*);

// Return codes
#define		PFQL_OK			0
#define		PFQL_ERROR		-1
#define		PFQL_INVREGEXP		-1
#define		PFQL_BENOTFOUND		-2
#define		PFQL_BEWRONGAPI 	-3
#define		PFQL_BEMISSINGSYM	-4
#define		PFQL_MALLOC		-5
#define		PFQL_NOBE		-6
#define		PFQL_BEINIT		-7
#define		PFQL_MSGNOTEX		-1

#ifdef __cplusplus
}
#endif

#endif // __PFQLIB_H