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