8d4b45d7f382a5d2d04987af291cabe91827887f
[citadel.git] / citadel / citadel.h
1 /*
2  * Main Citadel header file
3  *
4  * Copyright (c) 1987-2014 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       830             /* This version */
49 #define REV_MIN         591             /* Oldest compatible database */
50 #define EXPORT_REV_MIN  760             /* Oldest compatible export files */
51 #define LIBCITADEL_MIN  829             /* 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 ROOMNAMELEN     128     /* The size of a roomname string */
65                                          
66 #define USERNAME_SIZE   64      /* The size of a username string */
67 #define MAX_EDITORS     5       /* # of external editors supported */
68                                 /* MUST be at least 1 */
69
70 /*
71  * Message expiration policy stuff
72  */
73 typedef struct ExpirePolicy ExpirePolicy;
74 struct ExpirePolicy {
75         int expire_mode;
76         int expire_value;
77 };
78
79 #define EXPIRE_NEXTLEVEL        0       /* Inherit expiration policy    */
80 #define EXPIRE_MANUAL           1       /* Don't expire messages at all */
81 #define EXPIRE_NUMMSGS          2       /* Keep only latest n messages  */
82 #define EXPIRE_AGE              3       /* Expire messages after n days */
83
84
85 /*
86  * This struct stores a list of rooms with new messages which the client
87  * fetches from the server.  This allows the client to "march" through
88  * relevant rooms without having to ask the server each time where to go next.
89  */
90 typedef struct march march;
91 struct march {
92         struct march *next;
93         char march_name[ROOMNAMELEN];
94         unsigned int march_flags;
95         char march_floor;
96         char march_order;
97         unsigned int march_flags2;
98         int march_access;
99 };
100
101
102 /*
103  * User records.
104  */
105 typedef struct ctdluser ctdluser;
106 struct ctdluser {                       /* User record                      */
107         int version;                    /* Cit vers. which created this rec  */
108         uid_t uid;                      /* Associate with a unix account?    */
109         char password[32];              /* password                          */
110         unsigned flags;                 /* See US_ flags below               */
111         long timescalled;               /* Total number of logins            */
112         long posted;                    /* Number of messages ever submitted */
113         cit_uint8_t axlevel;            /* Access level                      */
114         long usernum;                   /* User number (never recycled)      */
115         time_t lastcall;                /* Date/time of most recent login    */
116         int USuserpurge;                /* Purge time (in days) for user     */
117         char fullname[64];              /* Display name (primary identifier) */
118 };
119
120
121 /* Bits which may appear in CitControl.MMflags.  Note that these don't
122  * necessarily pertain to the message base -- it's just a good place to
123  * store any global flags.
124  */
125 #define MM_VALID        4               /* New users need validating        */
126
127 /*
128  * Room records.
129  */
130 typedef struct ctdlroom ctdlroom;
131 struct ctdlroom {
132         char QRname[ROOMNAMELEN];       /* Name of room                     */
133         char QRpasswd[10];              /* Only valid if it's a private rm  */
134         long QRroomaide;                /* User number of room aide         */
135         long QRhighest;                 /* Highest message NUMBER in room   */
136         time_t QRgen;                   /* Generation number of room        */
137         unsigned QRflags;               /* See flag values below            */
138         char QRdirname[15];             /* Directory name, if applicable    */
139         long QRinfo;                    /* Info file update relative to msgs*/
140         char QRfloor;                   /* Which floor this room is on      */
141         time_t QRmtime;                 /* Date/time of last post           */
142         struct ExpirePolicy QRep;       /* Message expiration policy        */
143         long QRnumber;                  /* Globally unique room number      */
144         char QRorder;                   /* Sort key for room listing order  */
145         unsigned QRflags2;              /* Additional flags                 */
146         int QRdefaultview;              /* How to display the contents      */
147 };
148
149 /* Private rooms are always flagged with QR_PRIVATE.  If neither QR_PASSWORDED
150  * or QR_GUESSNAME is set, then it is invitation-only.  Passworded rooms are
151  * flagged with both QR_PRIVATE and QR_PASSWORDED while guess-name rooms are
152  * flagged with both QR_PRIVATE and QR_GUESSNAME.  NEVER set all three flags.
153  */
154
155 /*
156  * Miscellaneous
157  */
158 #define MES_NORMAL      65              /* Normal message                   */
159 #define MES_ANONONLY    66              /* "****" header                    */
160 #define MES_ANONOPT     67              /* "Anonymous" header               */
161
162 #define MES_ERROR       (-1)    /* Can't send message due to bad address   */
163 #define MES_LOCAL       0       /* Local message, do no network processing */
164 #define MES_INTERNET    1       /* Convert msg and send as Internet mail   */
165 #define MES_IGNET       2       /* Process recipient and send via Cit net  */
166
167 /****************************************************************************/
168
169 /*
170  * Floor record.  The floor number is implicit in its location in the file.
171  */
172 typedef struct floor floor;
173 struct floor {
174         unsigned short f_flags;         /* flags */
175         char f_name[256];               /* name of floor */
176         int f_ref_count;                /* reference count */
177         struct ExpirePolicy f_ep;       /* default expiration policy */
178 };
179
180 #define F_INUSE         1               /* floor is in use */
181
182
183 /*
184  * Values used internally for function call returns, etc.
185  */
186
187 #define NEWREGISTER     0               /* new user to register */
188 #define REREGISTER      1               /* existing user reregistering */
189
190 /* number of items which may be handled by the CONF command */
191 #define NUM_CONFIGS 70
192
193 #define TRACE   syslog(LOG_DEBUG, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
194
195 #ifndef LONG_MAX
196 #define LONG_MAX 2147483647L
197 #endif
198
199 /*
200  * Authentication modes
201  */
202 #define AUTHMODE_NATIVE         0       /* Native (self-contained or "black box") */
203 #define AUTHMODE_HOST           1       /* Authenticate against the host OS user database */
204 #define AUTHMODE_LDAP           2       /* Authenticate against an LDAP server with RFC 2307 schema */
205 #define AUTHMODE_LDAP_AD        3       /* Authenticate against non-standard MS Active Directory LDAP */
206
207 #ifdef __cplusplus
208 }
209 #endif
210
211 #endif /* CITADEL_H */