Began removing $Id$ tags. This will be an ongoing process.
[citadel.git] / citadel / citadel.h
1 /*
2  * Main Citadel header file
3  *
4  * Copyright (c) 1987-2010 by the citadel.org team
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 /* system customizations are in sysconfig.h */
22
23 #ifndef CITADEL_H
24 #define CITADEL_H
25 /* #include <dmalloc.h> uncomment if using dmalloc */
26
27 #include "sysdep.h"
28 #include <limits.h>
29 #include "sysconfig.h"
30 #include "typesize.h"
31 #include "ipcdef.h"
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 /*
38  * Text description of this software
39  * (We used to define this ourselves, but why bother when
40  * the GNU build tools do it for us?)
41  */
42 #define CITADEL PACKAGE_STRING
43
44 /*
45  * REV_LEVEL is the current version number (multiplied by 100 to avoid having
46  * to fiddle with the decimal).  REV_MIN is the oldest version of Citadel
47  * whose data files are compatible with the current version.  If the data files
48  * are older than REV_MIN, none of the programs will work until the setup
49  * program is run again to bring things up to date.  EXPORT_REV_MIN is the
50  * oldest version of Citadel whose export files we can read.  The latter is
51  * usually more strict because you're not really supposed to dump/load and
52  * upgrade at the same time.
53  */
54 #define REV_LEVEL       783             /* This version */
55 #define REV_MIN         591             /* Oldest compatible database */
56 #define EXPORT_REV_MIN  760             /* Oldest compatible export files */
57 #define LIBCITADEL_MIN  781             /* Minimum required version of libcitadel */
58
59 #define SERVER_TYPE 0                   /* zero for stock Citadel; other developers please
60                                            obtain SERVER_TYPE codes for your implementations */
61
62 #ifdef LIBCITADEL_VERSION_NUMBER
63 #if LIBCITADEL_VERSION_NUMBER < LIBCITADEL_MIN
64 #error libcitadel is too old.  Please upgrade it before continuing.
65 #endif
66 #endif
67
68 /* Various length constants */
69
70 #define UGLISTLEN       100     /* you get a ungoto list of this size */
71 #define ROOMNAMELEN     128     /* The size of a roomname string */
72 #define NONCE_SIZE      128     /* Added by <bc> to allow for APOP auth 
73                                  * it is BIG becuase there is a hostname
74                                  * in the nonce, as per the APOP RFC.
75                                  */
76                                          
77 #define USERNAME_SIZE   64      /* The size of a username string */
78 #define MAX_EDITORS     5       /* # of external editors supported */
79                                 /* MUST be at least 1 */
80
81 /*
82  * Message expiration policy stuff
83  */
84 typedef struct ExpirePolicy ExpirePolicy;
85 struct ExpirePolicy {
86 /*
87 #include "datadefinitions.h"
88 #include "dtds/expirepolicy-defs.h"
89 #include "undef_data.h"
90 */
91         int expire_mode;
92         int expire_value;
93 };
94
95 #define EXPIRE_NEXTLEVEL        0       /* Inherit expiration policy    */
96 #define EXPIRE_MANUAL           1       /* Don't expire messages at all */
97 #define EXPIRE_NUMMSGS          2       /* Keep only latest n messages  */
98 #define EXPIRE_AGE              3       /* Expire messages after n days */
99
100
101 /*
102  * This struct stores a list of rooms with new messages which the client
103  * fetches from the server.  This allows the client to "march" through
104  * relevant rooms without having to ask the server each time where to go next.
105  */
106 typedef struct march march;
107 struct march {
108 /*
109 #include "datadefinitions.h"
110 #include "dtds/march-defs.h"
111 #include "undef_data.h"
112 */
113         struct march *next;
114         char march_name[ROOMNAMELEN];
115         unsigned int march_flags;
116         char march_floor;
117         char march_order;
118         unsigned int march_flags2;
119         int march_access;
120 };
121
122 #define NODENAME                config.c_nodename
123 #define FQDN                    config.c_fqdn
124 #define HUMANNODE               config.c_humannode
125 #define PHONENUM                config.c_phonenum
126 #define CTDLUID                 config.c_ctdluid
127 #define CREATAIDE               config.c_creataide
128 #define REGISCALL               config.c_regiscall
129 #define TWITDETECT              config.c_twitdetect
130 #define TWITROOM                config.c_twitroom
131 #define RESTRICT_INTERNET       config.c_restrict
132
133 /*
134  * User records.
135  */
136 typedef struct ctdluser ctdluser;
137 struct ctdluser {                       /* User record                      */
138 /*
139 #include "datadefinitions.h"
140 #include "dtds/user-defs.h"
141 #include "undef_data.h"
142 */
143         int version;                    /* Cit vers. which created this rec  */
144         uid_t uid;                      /* Associate with a unix account?    */
145         char password[32];              /* password                          */
146         unsigned flags;                 /* See US_ flags below               */
147         long timescalled;               /* Total number of logins            */
148         long posted;                    /* Number of messages ever submitted */
149         cit_uint8_t axlevel;            /* Access level                      */
150         long usernum;                   /* User number (never recycled)      */
151         time_t lastcall;                /* Date/time of most recent login    */
152         int USuserpurge;                /* Purge time (in days) for user     */
153         char fullname[64];              /* Display name (primary identifier) */
154         cit_uint8_t USscreenwidth;      /* Screen width (for textmode users) */
155         cit_uint8_t USscreenheight;     /* Screen height(for textmode users) */
156 };
157
158
159 /* Bits which may appear in CitControl.MMflags.  Note that these don't
160  * necessarily pertain to the message base -- it's just a good place to
161  * store any global flags.
162  */
163 #define MM_VALID        4               /* New users need validating        */
164
165 /*
166  * Room records.
167  */
168 typedef struct ctdlroom ctdlroom;
169 struct ctdlroom {
170 /*
171 #include "datadefinitions.h"
172 #include "dtds/room-defs.h"
173 #include "undef_data.h"
174 */
175         char QRname[ROOMNAMELEN];       /* Name of room                     */
176         char QRpasswd[10];              /* Only valid if it's a private rm  */
177         long QRroomaide;                /* User number of room aide         */
178         long QRhighest;                 /* Highest message NUMBER in room   */
179         time_t QRgen;                   /* Generation number of room        */
180         unsigned QRflags;               /* See flag values below            */
181         char QRdirname[15];             /* Directory name, if applicable    */
182         long QRinfo;                    /* Info file update relative to msgs*/
183         char QRfloor;                   /* Which floor this room is on      */
184         time_t QRmtime;                 /* Date/time of last post           */
185         struct ExpirePolicy QRep;       /* Message expiration policy        */
186         long QRnumber;                  /* Globally unique room number      */
187         char QRorder;                   /* Sort key for room listing order  */
188         unsigned QRflags2;              /* Additional flags                 */
189         int QRdefaultview;              /* How to display the contents      */
190 };
191
192 /* Private rooms are always flagged with QR_PRIVATE.  If neither QR_PASSWORDED
193  * or QR_GUESSNAME is set, then it is invitation-only.  Passworded rooms are
194  * flagged with both QR_PRIVATE and QR_PASSWORDED while guess-name rooms are
195  * flagged with both QR_PRIVATE and QR_GUESSNAME.  NEVER set all three flags.
196  */
197
198 /*
199  * Miscellaneous
200  */
201 #define MES_NORMAL      65              /* Normal message                   */
202 #define MES_ANONONLY    66              /* "****" header                    */
203 #define MES_ANONOPT     67              /* "Anonymous" header               */
204
205 #define MES_ERROR       (-1)    /* Can't send message due to bad address   */
206 #define MES_LOCAL       0       /* Local message, do no network processing */
207 #define MES_INTERNET    1       /* Convert msg and send as Internet mail   */
208 #define MES_IGNET       2       /* Process recipient and send via Cit net  */
209
210 /****************************************************************************/
211
212 /*
213  * Floor record.  The floor number is implicit in its location in the file.
214  */
215 typedef struct floor floor;
216 struct floor {
217 /*
218 #include "datadefinitions.h"
219 #include "dtds/floor-defs.h"
220 #include "undef_data.h"
221 */
222         unsigned short f_flags;         /* flags */
223         char f_name[256];               /* name of floor */
224         int f_ref_count;                /* reference count */
225         struct ExpirePolicy f_ep;       /* default expiration policy */
226 };
227
228 #define F_INUSE         1               /* floor is in use */
229
230
231 /*
232  * Values used internally for function call returns, etc.
233  */
234
235 #define NEWREGISTER     0               /* new user to register */
236 #define REREGISTER      1               /* existing user reregistering */
237
238 #define READ_HEADER     2
239 #define READ_MSGBODY    3
240
241 /* commands we can send to the stty_ctdl() routine */
242 #define SB_NO_INTR      0               /* set to Citadel client mode, i/q disabled */
243 #define SB_YES_INTR     1               /* set to Citadel client mode, i/q enabled */
244 #define SB_SAVE         2               /* save settings */
245 #define SB_RESTORE      3               /* restore settings */
246 #define SB_LAST         4               /* redo the last command sent */
247
248 #define NEXT_KEY        15
249 #define STOP_KEY        3
250
251 /* server exit codes */
252 #define EXIT_NORMAL     0               /* server terminated normally */
253                                         /* 1 through 63 reserved for signals */
254 #define EXIT_NULL       64              /* EOF on server command input */
255
256 /* citadel.rc stuff */
257 #define RC_NO           0               /* always no */
258 #define RC_YES          1               /* always yes */
259 #define RC_DEFAULT      2               /* setting depends on user config */
260
261 /* keepalives */
262 enum {
263         KA_NO,                          /* no keepalives */
264         KA_YES,                         /* full keepalives */
265         KA_HALF                         /* half keepalives */
266 };
267
268 /* for <;G>oto and <;S>kip commands */
269 #define GF_GOTO         0               /* <;G>oto floor mode */
270 #define GF_SKIP         1               /* <;S>kip floor mode */
271 #define GF_ZAP          2               /* <;Z>ap floor mode */
272
273 /*
274  * MIME types used in Citadel for configuration stuff
275  */
276 #define SPOOLMIME       "application/x-citadel-delivery-list"
277 #define INTERNETCFG     "application/x-citadel-internet-config"
278 #define IGNETCFG        "application/x-citadel-ignet-config"
279 #define IGNETMAP        "application/x-citadel-ignet-map"
280 #define FILTERLIST      "application/x-citadel-filter-list"
281 #define SIEVECONFIG     "application/x-citadel-sieve-config"
282 #define XMPPMORTUARY    "application/x-citadel-xmpp-mortuary"
283
284 #define TRACE   CtdlLogPrintf(CTDL_DEBUG, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
285
286 #ifndef LONG_MAX
287 #define LONG_MAX 2147483647L
288 #endif
289
290 /*
291  * Authentication modes
292  */
293 #define AUTHMODE_NATIVE         0       /* Native (self-contained or "black box") */
294 #define AUTHMODE_HOST           1       /* Authenticate against the host OS user database */
295 #define AUTHMODE_LDAP           2       /* Authenticate against an LDAP server with RFC 2307 schema */
296 #define AUTHMODE_LDAP_AD        3       /* Authenticate against non-standard MS Active Directory LDAP */
297
298 #ifdef __cplusplus
299 }
300 #endif
301
302 #endif /* CITADEL_H */