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