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