summaryrefslogtreecommitdiffstats
path: root/exim_monitor/em_hdr.h
blob: ab37806b7a2e1c1f8bc4176990ee5d301eca1cef (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
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
/*************************************************
*                 Exim Monitor                   *
*************************************************/

/* Copyright (c) University of Cambridge 1995 - 2009 */
/* Copyright (c) The Exim Maintainers 2021 - 2022 */
/* See the file NOTICE for conditions of use and distribution. */


/* This is the general header file for all the modules that comprise
the exim monitor program. */

/* If this macro is defined, Eximon will anonymize all email addresses. This
feature is just so that screen shots can be obtained for documentation
purposes! */

/* #define ANONYMIZE */

/* System compilation parameters */

#define queue_index_size  10      /* Size of index into queue */

/* Assume most systems have statfs() unless os.h undefines this macro */

#define HAVE_STATFS

/* Bring in the system-dependent stuff */

#include "os.h"


/* ANSI C includes */

#include <ctype.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

/* Not-fully-ANSI systems (e.g. SunOS4 are missing some things) */

#ifndef SEEK_SET
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#endif

/* Unix includes */

#include <sys/types.h>
#include <errno.h>
#include <dirent.h>
#include <fcntl.h>
#include <pwd.h>
#include <grp.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>

/* The new standard is statvfs; some OS have statfs. Also arrange
to be able to cut it out altogether for way-out OS that don't have
anything. */

#ifdef HAVE_STATFS
#ifdef HAVE_SYS_STATVFS_H
#include <sys/statvfs.h>

#else
  #define statvfs statfs
  #ifdef HAVE_SYS_VFS_H
    #include <sys/vfs.h>
    #ifdef HAVE_SYS_STATFS_H
    #include <sys/statfs.h>
    #endif
  #endif
  #ifdef HAVE_SYS_MOUNT_H
  #include <sys/mount.h>
  #endif
#endif
#endif

#include <sys/wait.h>

/* Regular expression include */

#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>

/* Includes from the main source of Exim.  One of these days I should tidy up
this interface so that this kind of kludge isn't needed. */

#ifndef NS_MAXMSG
# define NS_MAXMSG 65535
#endif
typedef void * hctx;

#include "local_scan.h"
#include "macros.h"
#include "structs.h"
#include "blob.h"
#include "globals.h"
#include "hintsdb.h"
#include "hintsdb_structs.h"
#include "functions.h"
#include "osfunctions.h"

/* The sys/resource.h header on SunOS 4 causes trouble with the gcc
compiler. Just stuff the bit we want in here; pragmatic easy way out. */

#ifdef NO_SYS_RESOURCE_H
#define RLIMIT_NOFILE   6               /* maximum descriptor index + 1 */
struct rlimit {
        int     rlim_cur;               /* current (soft) limit */
        int     rlim_max;               /* maximum value for rlim_cur */
};
#else
#include <sys/time.h>
#include <sys/resource.h>
#endif

/* X11 includes */

#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/cursorfont.h>
#include <X11/keysym.h>
#include <X11/Shell.h>
#include <X11/Xaw/AsciiText.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Dialog.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/SimpleMenu.h>
#include <X11/Xaw/SmeBSB.h>
#include <X11/Xaw/SmeLine.h>
#include <X11/Xaw/TextSrc.h>
#include <X11/Xaw/TextSink.h>

/* These are required because exim monitor has its own munged
version of the stripchart widget. */

#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/XawInit.h>
#include <X11/Xaw/StripCharP.h>

extern WidgetClass mystripChartWidgetClass;



/*************************************************
*               Enumerations                     *
*************************************************/

/* Operations on the in-store message queue */

enum { queue_noop, queue_add };

/* Operations on the destinations queue */

enum { dest_noop, dest_add, dest_remove };


/*************************************************
*          Structure for destinations            *
*************************************************/

typedef struct dest_item {
  struct dest_item *next;
  struct dest_item *parent;
  uschar address[1];
} dest_item;



/*************************************************
*           Structure for queue items            *
*************************************************/

typedef struct queue_item {
  struct queue_item *next;
  struct queue_item *prev;
  struct dest_item  *destinations;
  int  input_time;
  int  update_time;
  int  size;
  uschar *sender;
  uschar name[17];
  uschar seen;
  uschar frozen;
  uschar dir_char;
} queue_item;


/*************************************************
*          Structure for queue skip items        *
*************************************************/

typedef struct skip_item {
  struct skip_item *next;
  time_t reveal;
  uschar text[1];
} skip_item;


/*************************************************
*           Structure for delivery displays      *
*************************************************/

typedef struct pipe_item {
  struct pipe_item *next;
  int fd;
  Widget widget;
} pipe_item;



/*************************************************
*                Global variables                *
*************************************************/

extern Display *X_display;         /* Current display */
extern XtAppContext X_appcon;      /* Application context */
extern XtActionsRec actionTable[]; /* Actions table */

extern XtTranslations queue_trans; /* translation table for queue text widget */
extern XtTranslations text_trans;  /* translation table for other text widgets */

extern Widget  dialog_ref_widget;   /* for positioning dialog box */
extern Widget  toplevel_widget;
extern Widget  log_widget;          /* widget for tail display */
extern Widget  queue_widget;        /* widget for queue display */
extern Widget  unhide_widget;       /* widget for unhide button */

extern FILE   *LOG;

extern int     action_output;       /* TRUE when wanting action command output */
extern int     action_queue_update; /* controls auto updates */
extern int     actionTableSize;     /* # entries in actionTable */
extern uschar  actioned_message[];  /* For menu handling */
extern uschar *action_required;
extern uschar *alternate_config;    /* Alternate Exim configuration file */

extern int     body_max;            /* Max size of body to display */

extern int     eximon_initialized;  /* TRUE when initialized */

extern int     log_buffer_size;     /* size of log buffer */
extern BOOL    log_datestamping;    /* TRUE if logs are datestamped */
extern int     log_depth;           /* depth of log tail window */
extern uschar *log_display_buffer;  /* to hold display text */
extern uschar *log_file;            /* supplied name of exim log file */
extern uschar  log_file_open[256];  /* actual open file */
extern uschar *log_font;            /* font for log display */
extern ino_t   log_inode;           /* the inode of the log file */
extern long int log_position;      /* position in log file */
extern int     log_width;           /* width of log tail window */

extern uschar *menu_event;          /* name of menu event */
extern int     menu_is_up;          /* TRUE when menu displayed */
extern int     min_height;          /* min window height */
extern int     min_width;           /* min window width */

extern pipe_item *pipe_chain;      /* for delivery displays */

extern uschar *qualify_domain;
extern int     queue_depth;         /* depth of queue window */
extern uschar *queue_font;          /* font for queue display */
extern int     queue_max_addresses; /* limit on per-message list */
extern skip_item *queue_skip;      /* for hiding bits of queue */
extern uschar *queue_stripchart_name; /* sic */
extern int     queue_update;        /* update interval */
extern int     queue_width;         /* width of queue window */

extern pcre2_code   *yyyymmdd_regex;    /* for matching yyyy-mm-dd */

extern uschar *size_stripchart;     /* path for size monitoring */
extern uschar *size_stripchart_name; /* name for size stripchart */
extern uschar *spool_directory;     /* Name of exim spool directory */
extern int     spool_is_split;      /* True if detected split spool */
extern int     start_small;         /* True to start with small window */
extern int     stripchart_height;   /* height of stripcharts */
extern int     stripchart_number;   /* number of stripcharts */
extern pcre2_code  **stripchart_regex;  /* vector of regexps */
extern uschar **stripchart_title;    /* vector of titles */
extern int    *stripchart_total;    /* vector of accumulating values */
extern int     stripchart_update;   /* update interval */
extern int     stripchart_width;    /* width of stripcharts */
extern int     stripchart_varstart; /* starting number for variable charts */

extern int     text_depth;          /* depth of text windows */
extern int     tick_queue_accumulator; /* For timing next auto update */

extern uschar *window_title;        /* title of the exim monitor window */


/*************************************************
*                Global functions                *
*************************************************/

extern XtActionProc dialogAction(Widget, XEvent *, String *, Cardinal *);

extern uschar *copystring(uschar *);
extern void    create_dialog(uschar *, uschar *);
extern void    create_stripchart(Widget, uschar *);
extern void    debug(char *, ...);
extern dest_item *find_dest(queue_item *, uschar *, int, BOOL);
extern queue_item *find_queue(uschar *, int, int);
extern void    init(int, uschar **);
extern void    menu_create(Widget, XEvent *, String *, Cardinal *);
extern void    NonMessageDialogue(uschar *);
extern void    queue_display(void);
extern void    read_log(void);
extern int     read_spool(uschar *);
extern int     read_spool_init(uschar *);
extern void    read_spool_tidy(void);
extern int     repaint_window(StripChartWidget, int, int);
extern void    scan_spool_input(int);
extern void    stripchart_init(void);
extern void    text_empty(Widget);
extern void    text_show(Widget, uschar *);
extern void    text_showf(Widget, char *, ...);
extern void    xs_SetValues(Widget, Cardinal, ...);

/* End of em_hdr.h */