2 * Main declarations file for the Citadel server
4 * Copyright (c) 1987-2015 by the citadel.org team
6 * This program is open source software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
19 #define INLINE __inline__
26 #define OPENSSL_NO_KRB5 /* work around redhat b0rken ssl headers */
27 #include <openssl/ssl.h>
31 * New format for a message in memory
34 int cm_magic; /* Self-check (NOT SAVED TO DISK) */
35 char cm_anon_type; /* Anonymous or author-visible */
36 char cm_format_type; /* Format type */
37 char *cm_fields[256]; /* Data fields */
38 long cm_lengths[256]; /* size of datafields */
39 unsigned int cm_flags; /* How to handle (NOT SAVED TO DISK) */
42 #define CTDLMESSAGE_MAGIC 0x159d
43 #define CM_SKIP_HOOKS 0x01 /* Don't run server-side handlers */
46 /* Data structure returned by validate_recipients() */
47 typedef struct __recptypes {
66 #define RECPTYPES_MAGIC 0xfeeb
69 #define CTDLEXIT_SHUTDOWN 0 /* Normal shutdown; do NOT auto-restart */
72 * Exit codes 101 through 109 are used for conditions in which
73 * we deliberately do NOT want the service to automatically
76 #define CTDLEXIT_CONFIG 101 /* Could not read citadel.config */
77 #define CTDLEXIT_CONTROL 102 /* Could not acquire lock */
78 #define CTDLEXIT_HOME 103 /* Citadel home directory not found */
79 #define CTDLEXIT_OOD 104 /* Out Of Date config - rerun setup */
80 #define CTDLEXIT_DB 105 /* Unable to initialize database */
81 #define CTDLEXIT_LIBCITADEL 106 /* Incorrect version of libcitadel */
82 #define CTDL_EXIT_UNSUP_AUTH 107 /* Unsupported auth mode configured */
83 #define CTDLEXIT_UNUSER 108 /* Could not determine uid to run as */
86 * Reasons why a session would be terminated (set CC->kill_me to these values)
91 KILLME_CLIENT_LOGGED_OUT,
93 KILLME_CLIENT_DISCONNECTED,
95 KILLME_SERVER_SHUTTING_DOWN,
96 KILLME_MAX_SESSIONS_EXCEEDED,
97 KILLME_ADMIN_TERMINATE,
98 KILLME_SELECT_INTERRUPTED,
101 KILLME_SIMULATION_WORKER,
104 KILLME_READSTRING_FAILED,
105 KILLME_MALLOC_FAILED,
108 KILLME_ILLEGAL_MANAGESIEVE_COMMAND,
114 #define CS_STEALTH 1 /* stealth mode */
115 #define CS_CHAT 2 /* chat mode */
116 #define CS_POSTING 4 /* Posting */
120 * This is the control record for the message base...
123 long MMhighest; /* highest message number in file */
124 unsigned MMflags; /* Global system flags */
125 long MMnextuser; /* highest user number on system */
126 long MMnextroom; /* highest room number on system */
127 int MM_hosted_upgrade_level; /* Server-hosted upgrade level */
128 int MM_fulltext_wordbreaker; /* ID of wordbreaker in use */
129 long MMfulltext; /* highest message number indexed */
130 int MMdbversion; /* Version of Berkeley DB used on previous server run */
133 extern int ScheduledShutdown;
134 extern struct CitControl CitControl;
135 extern uid_t ctdluid;
137 struct ExpressMessage {
138 struct ExpressMessage *next;
139 time_t timestamp; /* When this message was sent */
140 unsigned flags; /* Special instructions */
141 char sender[256]; /* Name of sending user */
142 char sender_email[256]; /* Email or JID of sending user */
143 char *text; /* Message text (if applicable) */
146 #define EM_BROADCAST 1 /* Broadcast message */
147 #define EM_GO_AWAY 2 /* Server requests client log off */
148 #define EM_CHAT 4 /* Server requests client enter chat */
151 * Various things we need to lock and unlock
194 * message transfer formats
197 MT_CITADEL, /* Citadel proprietary */
198 MT_RFC822, /* RFC822 */
199 MT_MIME, /* MIME-formatted message */
200 MT_DOWNLOAD, /* Download a component */
201 MT_SPEW_SECTION /* Download a component in a single operation */
205 * Message format types in the database
207 #define FMT_CITADEL 0 /* Citadel vari-format (proprietary) */
208 #define FMT_FIXED 1 /* Fixed format (proprietary) */
209 #define FMT_RFC822 4 /* Standard (headers are in M field) */
213 * Citadel DataBases (define one for each cdb we need to open)
216 CDB_MSGMAIN, /* message base */
217 CDB_USERS, /* user file */
218 CDB_ROOMS, /* room index */
219 CDB_FLOORTAB, /* floor index */
220 CDB_MSGLISTS, /* room message lists */
221 CDB_VISIT, /* user/room relationships */
222 CDB_DIRECTORY, /* address book directory */
223 CDB_USETABLE, /* network use table */
224 CDB_BIGMSGS, /* larger message bodies */
225 CDB_FULLTEXT, /* full text search index */
226 CDB_EUIDINDEX, /* locate msgs by EUID */
227 CDB_USERSBYNUMBER, /* index of users by number */
228 CDB_OPENID, /* associates OpenIDs with users */
229 CDB_CONFIG, /* system configuration database */
230 MAXCDB /* total number of CDB's defined */
240 * Event types can't be enum'ed, because they must remain consistent between
241 * builds (to allow for binary modules built somewhere else)
243 #define EVT_STOP 0 /* Session is terminating */
244 #define EVT_START 1 /* Session is starting */
245 #define EVT_LOGIN 2 /* A user is logging in */
246 #define EVT_NEWROOM 3 /* Changing rooms */
247 #define EVT_LOGOUT 4 /* A user is logging out */
248 #define EVT_SETPASS 5 /* Setting or changing password */
249 #define EVT_CMD 6 /* Called after each server command */
250 #define EVT_RWHO 7 /* An RWHO command is being executed */
251 #define EVT_ASYNC 8 /* Doing asynchronous messages */
252 #define EVT_STEALTH 9 /* Entering stealth mode */
253 #define EVT_UNSTEALTH 10 /* Exiting stealth mode */
255 #define EVT_TIMER 50 /* Timer events are called once per minute
256 and are not tied to any session */
257 #define EVT_HOUSE 51 /* as needed houskeeping stuff */
258 #define EVT_SHUTDOWN 52 /* Server is shutting down */
260 #define EVT_PURGEUSER 100 /* Deleting a user */
261 #define EVT_NEWUSER 102 /* Creating a user */
263 #define EVT_BEFOREREAD 200
264 #define EVT_BEFORESAVE 201
265 #define EVT_AFTERSAVE 202
266 #define EVT_SMTPSCAN 203 /* called before submitting a msg from SMTP */
267 #define EVT_AFTERUSRMBOXSAVE 204 /* called afte a message was saved into a users inbox */
268 /* Priority levels for paging functions (lower is better) */
270 XMSG_PRI_LOCAL, /* Other users on -this- server */
271 XMSG_PRI_REMOTE, /* Other users on a Citadel network (future) */
272 XMSG_PRI_FOREIGN, /* Contacts on foreign instant message hosts */
277 /* Defines the relationship of a user to a particular room */
278 typedef struct __visit {
283 unsigned int v_flags;
285 char v_answered[SIZ];
289 #define V_FORGET 1 /* User has zapped this room */
290 #define V_LOCKOUT 2 /* User is locked out of this room */
291 #define V_ACCESS 4 /* Access is granted to this room */
294 /* Supplementary data for a message on disk
295 * These are kept separate from the message itself for one of two reasons:
296 * 1. Either their values may change at some point after initial save, or
297 * 2. They are merely caches of data which exist somewhere else, for speed.
300 long meta_msgnum; /* Message number in *local* message base */
301 int meta_refcount; /* Number of rooms pointing to this msg */
302 char meta_content_type[64]; /* Cached MIME content-type */
303 long meta_rfc822_length; /* Cache of RFC822-translated msg length */
304 char mimetype[64]; /* if we were able to guess the mimetype for the data */
307 /* Calls to AdjRefCount() are queued and deferred, so the user doesn't
308 * have to wait for various disk-intensive operations to complete synchronously.
309 * This is the record format.
312 long arcq_msgnum; /* Message number being adjusted */
313 int arcq_delta; /* Adjustment ( usually 1 or -1 ) */
318 * Serialization routines use this struct to return a pointer and a length
327 * The S_USETABLE database is used in several modules now, so we define its format here.
336 /* Preferred field order */
337 /* ********** Important fields */
338 /* *************** Semi-important fields */
339 /* ** internal only */
340 /* * Message text (MUST be last) */
341 ///#define FORDER "IPTAFONHRDBCEWJGKLQSVXZYU12M"
343 typedef enum _MsgField {
372 #endif /* SERVER_H */