Start
[exim.git] / src / exim_monitor / em_hdr.h
1 /* $Cambridge: exim/src/exim_monitor/em_hdr.h,v 1.1 2004/10/07 10:39:01 ph10 Exp $ */; iline//
2 /*************************************************
3 * Exim Monitor *
4 *************************************************/
5
6 /* Copyright (c) University of Cambridge 1995 - 2004 */
7 /* See the file NOTICE for conditions of use and distribution. */
8
9
10 /* This is the general header file for all the modules that comprise
11 the exim monitor program. */
12
13 /* If this macro is defined, Eximon will anonymize all email addresses. This
14 feature is just so that screen shots can be obtained for documentation
15 purposes! */
16
17 /* #define ANONYMIZE */
18
19 /* System compilation parameters */
20
21 #define queue_index_size 10 /* Size of index into queue */
22
23 /* Assume most systems have statfs() unless os.h undefines this macro */
24
25 #define HAVE_STATFS
26
27 /* Bring in the system-dependent stuff */
28
29 #include "os.h"
30
31
32 /* ANSI C includes */
33
34 #include <ctype.h>
35 #include <setjmp.h>
36 #include <signal.h>
37 #include <stdarg.h>
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <string.h>
41 #include <time.h>
42
43 /* Not-fully-ANSI systems (e.g. SunOS4 are missing some things) */
44
45 #ifndef SEEK_SET
46 #define SEEK_SET 0
47 #define SEEK_CUR 1
48 #define SEEK_END 2
49 #endif
50
51 /* Unix includes */
52
53 #include <sys/types.h>
54 #include <errno.h>
55 #include <dirent.h>
56 #include <fcntl.h>
57 #include <pwd.h>
58 #include <grp.h>
59 #include <sys/param.h>
60 #include <sys/stat.h>
61 #include <unistd.h>
62
63 /* The new standard is statvfs; some OS have statfs. Also arrange
64 to be able to cut it out altogether for way-out OS that don't have
65 anything. */
66
67 #ifdef HAVE_STATFS
68 #ifdef HAVE_SYS_STATVFS_H
69 #include <sys/statvfs.h>
70
71 #else
72 #define statvfs statfs
73 #ifdef HAVE_SYS_VFS_H
74 #include <sys/vfs.h>
75 #ifdef HAVE_SYS_STATFS_H
76 #include <sys/statfs.h>
77 #endif
78 #endif
79 #ifdef HAVE_SYS_MOUNT_H
80 #include <sys/mount.h>
81 #endif
82 #endif
83 #endif
84
85 #include <sys/wait.h>
86
87 /* Regular expression include */
88
89 #include "pcre/pcre.h"
90
91 /* Includes from the main source of Exim. We need to have MAXPACKET defined for
92 the benefit of structs.h. One of these days I should tidy up this interface so
93 that this kind of kludge isn't needed. */
94
95 #define MAXPACKET 1024
96
97 #include "mytypes.h"
98 #include "macros.h"
99 #include "config.h"
100
101 #include "local_scan.h"
102 #include "structs.h"
103 #include "globals.h"
104 #include "functions.h"
105 #include "osfunctions.h"
106 #include "store.h"
107
108 /* The sys/resource.h header on SunOS 4 causes trouble with the gcc
109 compiler. Just stuff the bit we want in here; pragmatic easy way out. */
110
111 #ifdef NO_SYS_RESOURCE_H
112 #define RLIMIT_NOFILE 6 /* maximum descriptor index + 1 */
113 struct rlimit {
114 int rlim_cur; /* current (soft) limit */
115 int rlim_max; /* maximum value for rlim_cur */
116 };
117 #else
118 #include <sys/time.h>
119 #include <sys/resource.h>
120 #endif
121
122 /* X11 includes */
123
124 #include <X11/Xlib.h>
125 #include <X11/Intrinsic.h>
126 #include <X11/StringDefs.h>
127 #include <X11/cursorfont.h>
128 #include <X11/keysym.h>
129 #include <X11/Shell.h>
130 #include <X11/Xaw/AsciiText.h>
131 #include <X11/Xaw/Command.h>
132 #include <X11/Xaw/Form.h>
133 #include <X11/Xaw/Dialog.h>
134 #include <X11/Xaw/Label.h>
135 #include <X11/Xaw/SimpleMenu.h>
136 #include <X11/Xaw/SmeBSB.h>
137 #include <X11/Xaw/SmeLine.h>
138 #include <X11/Xaw/TextSrc.h>
139 #include <X11/Xaw/TextSink.h>
140
141 /* These are required because exim monitor has its own munged
142 version of the stripchart widget. */
143
144 #include <X11/IntrinsicP.h>
145 #include <X11/StringDefs.h>
146 #include <X11/Xaw/XawInit.h>
147 #include <X11/Xaw/StripCharP.h>
148
149 extern WidgetClass mystripChartWidgetClass;
150
151
152
153 /*************************************************
154 * Enumerations *
155 *************************************************/
156
157 /* Operations on the in-store message queue */
158
159 enum { queue_noop, queue_add };
160
161 /* Operations on the destinations queue */
162
163 enum { dest_noop, dest_add, dest_remove };
164
165
166 /*************************************************
167 * Structure for destinations *
168 *************************************************/
169
170 typedef struct dest_item {
171 struct dest_item *next;
172 struct dest_item *parent;
173 uschar address[1];
174 } dest_item;
175
176
177
178 /*************************************************
179 * Structure for queue items *
180 *************************************************/
181
182 typedef struct queue_item {
183 struct queue_item *next;
184 struct queue_item *prev;
185 struct dest_item *destinations;
186 int input_time;
187 int update_time;
188 int size;
189 uschar *sender;
190 uschar name[17];
191 uschar seen;
192 uschar frozen;
193 uschar dir_char;
194 } queue_item;
195
196
197 /*************************************************
198 * Structure for queue skip items *
199 *************************************************/
200
201 typedef struct skip_item {
202 struct skip_item *next;
203 time_t reveal;
204 uschar text[1];
205 } skip_item;
206
207
208 /*************************************************
209 * Structure for delivery displays *
210 *************************************************/
211
212 typedef struct pipe_item {
213 struct pipe_item *next;
214 int fd;
215 Widget widget;
216 } pipe_item;
217
218
219
220 /*************************************************
221 * Global variables *
222 *************************************************/
223
224 extern Display *X_display; /* Current display */
225 extern XtAppContext X_appcon; /* Application context */
226 extern XtActionsRec actionTable[]; /* Actions table */
227
228 extern XtTranslations queue_trans; /* translation table for queue text widget */
229 extern XtTranslations text_trans; /* translation table for other text widgets */
230
231 extern Widget dialog_ref_widget; /* for positioning dialog box */
232 extern Widget toplevel_widget;
233 extern Widget log_widget; /* widget for tail display */
234 extern Widget queue_widget; /* widget for queue display */
235 extern Widget unhide_widget; /* widget for unhide button */
236
237 extern FILE *LOG;
238
239 extern int action_output; /* TRUE when wanting action command output */
240 extern int action_queue_update; /* controls auto updates */
241 extern int actionTableSize; /* # entries in actionTable */
242 extern uschar actioned_message[]; /* For menu handling */
243 extern uschar *action_required;
244 extern uschar *alternate_config; /* Alternate Exim configuration file */
245
246 extern int body_max; /* Max size of body to display */
247
248 extern int eximon_initialized; /* TRUE when initialized */
249
250 extern int log_buffer_size; /* size of log buffer */
251 extern BOOL log_datestamping; /* TRUE if logs are datestamped */
252 extern int log_depth; /* depth of log tail window */
253 extern uschar *log_display_buffer; /* to hold display text */
254 extern uschar *log_file; /* supplied name of exim log file */
255 extern uschar log_file_open[256]; /* actual open file */
256 extern uschar *log_font; /* font for log display */
257 extern ino_t log_inode; /* the inode of the log file */
258 extern long int log_position; /* position in log file */
259 extern int log_width; /* width of log tail window */
260
261 extern uschar *menu_event; /* name of menu event */
262 extern int menu_is_up; /* TRUE when menu displayed */
263 extern int min_height; /* min window height */
264 extern int min_width; /* min window width */
265
266 extern pipe_item *pipe_chain; /* for delivery displays */
267
268 extern uschar *qualify_domain;
269 extern int queue_depth; /* depth of queue window */
270 extern uschar *queue_font; /* font for queue display */
271 extern int queue_max_addresses; /* limit on per-message list */
272 extern skip_item *queue_skip; /* for hiding bits of queue */
273 extern uschar *queue_stripchart_name; /* sic */
274 extern int queue_update; /* update interval */
275 extern int queue_width; /* width of queue window */
276
277 extern pcre *yyyymmdd_regex; /* for matching yyyy-mm-dd */
278
279 extern uschar *size_stripchart; /* path for size monitoring */
280 extern uschar *size_stripchart_name; /* name for size stripchart */
281 extern uschar *spool_directory; /* Name of exim spool directory */
282 extern int spool_is_split; /* True if detected split spool */
283 extern int start_small; /* True to start with small window */
284 extern int stripchart_height; /* height of stripcharts */
285 extern int stripchart_number; /* number of stripcharts */
286 extern pcre **stripchart_regex; /* vector of regexps */
287 extern uschar **stripchart_title; /* vector of titles */
288 extern int *stripchart_total; /* vector of accumulating values */
289 extern int stripchart_update; /* update interval */
290 extern int stripchart_width; /* width of stripcharts */
291 extern int stripchart_varstart; /* starting number for variable charts */
292
293 extern int text_depth; /* depth of text windows */
294 extern int tick_queue_accumulator; /* For timing next auto update */
295
296 extern uschar *window_title; /* title of the exim monitor window */
297
298
299 /*************************************************
300 * Global functions *
301 *************************************************/
302
303 extern XtActionProc dialogAction(Widget, XEvent *, String *, Cardinal *);
304
305 extern uschar *copystring(uschar *);
306 extern void create_dialog(uschar *, uschar *);
307 extern void create_stripchart(Widget, uschar *);
308 extern void debug(char *, ...);
309 extern dest_item *find_dest(queue_item *, uschar *, int, BOOL);
310 extern queue_item *find_queue(uschar *, int, int);
311 extern void init(int, uschar **);
312 extern void menu_create(Widget, XEvent *, String *, Cardinal *);
313 extern void NonMessageDialogue(uschar *);
314 extern void queue_display(void);
315 extern void read_log(void);
316 extern int read_spool(uschar *);
317 extern int read_spool_init(uschar *);
318 extern void read_spool_tidy(void);
319 extern int repaint_window(StripChartWidget, int, int);
320 extern void scan_spool_input(int);
321 extern void stripchart_init(void);
322 extern void text_empty(Widget);
323 extern void text_show(Widget, uschar *);
324 extern void text_showf(Widget, char *, ...);
325 extern void xs_SetValues(Widget, Cardinal, ...);
326
327 /* End of em_hdr.h */