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