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