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