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