* Reworked all the "list rooms" operations so that they only require one
[citadel.git] / citadel / citadel.h
1 /*
2  * $Id$
3  *
4  * main Citadel/UX 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
13 /* Build Citadel with the calendar service only if the header *and*
14  * library for libical are both present.
15  */
16 #ifdef HAVE_LIBICAL
17 #ifdef HAVE_ICAL_H
18 #define CITADEL_WITH_CALENDAR_SERVICE 1
19 #endif
20 #endif
21
22 #include "sysdep.h"
23 #include <limits.h>
24 #include "sysconfig.h"
25 #include "typesize.h"
26 #include "ipcdef.h"
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 /*
33  * Text description of this software
34  */
35 #define CITADEL "Citadel/UX 6.06"
36
37 /*
38  * REV_LEVEL is the current version number (multiplied by 100 to avoid having
39  * to fiddle with the decimal).  REV_MIN is the oldest version of Citadel
40  * whose data files are compatible with the current version.  If the data files
41  * are older than REV_MIN, none of the programs will work until the setup
42  * program is run again to bring things up to date.
43  */
44 #define REV_LEVEL       606             /* This version */
45 #define REV_MIN         591             /* Oldest compatible version */
46
47 #define SERVER_TYPE 0   /* zero for stock Citadel/UX; other developers please
48                            obtain SERVER_TYPE codes for your implementations */
49
50 /*
51  * This is a better implementation of tolower() than that found on some
52  * systems (there are operating systems out there on which tolower() will
53  * screw up if you give it a character that is already lower case).
54  */
55 #ifdef  tolower
56 #undef  tolower
57 #endif
58 #define tolower(x)      ( ((x>='A')&&(x<='Z')) ? (x+'a'-'A') : x )
59 #define NEW_CONFIG
60
61 /* Various length constants */
62
63 #define UGLISTLEN   100   /* you get a ungoto list of this size */
64 #define ROOMNAMELEN     128             /* The size of a roomname string */
65 #define NONCE_SIZE      128             /* Added by <bc> to allow for APOP auth 
66                                          * it is BIG becuase there is a hostname
67                                          * in the nonce, as per the APOP RFC.
68                                          */
69                                          
70 #define USERNAME_SIZE   64              /* The size of a username string */
71 #define MAX_EDITORS     5               /* # of external editors supported */
72                                         /* MUST be at least 1 */
73
74 /*
75  * Message expiration policy stuff
76  */
77 struct ExpirePolicy {
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  * Global system configuration 
90  */
91 struct config {
92         char c_nodename[16];            /* Unqualified "short" nodename     */
93         char c_fqdn[64];                /* Fully Qualified Domain Name      */
94         char c_humannode[21];           /* Long name of system              */
95         char c_phonenum[16];            /* Dialup number of system          */
96         uid_t c_bbsuid;                 /* UID of the bbs-only user         */
97         char c_creataide;               /* room creator = room aide  flag   */
98         int c_sleeping;                 /* watchdog timer setting           */
99         char c_initax;                  /* initial access level             */
100         char c_regiscall;               /* call number to register on       */
101         char c_twitdetect;              /* twit detect flag                 */
102         char c_twitroom[ROOMNAMELEN];   /* twit detect msg move to room     */
103         char c_moreprompt[80];          /* paginator prompt                 */
104         char c_restrict;                /* restrict Internet mail flag      */
105         long c_msgbase;                 /* size of message base (obsolete)  */
106         char c_bbs_city[32];            /* physical location of server      */
107         char c_sysadm[26];              /* name of system administrator     */
108         char c_bucket_dir[15];          /* bit bucket for files...          */
109         int c_setup_level;              /* what rev level we've setup to    */
110         int c_maxsessions;              /* maximum concurrent sessions      */
111         char c_net_password[20];        /* system net password (obsolete)   */
112         int c_port_number;              /* Cit listener port (usually 504)  */
113         int c_ipgm_secret;              /* Internal program authentication  */
114         struct ExpirePolicy c_ep;       /* System default msg expire policy */
115         int c_userpurge;                /* System default user purge (days) */
116         int c_roompurge;                /* System default room purge (days) */
117         char c_logpages[ROOMNAMELEN];   /* Room to log pages to (or not)    */
118         char c_createax;                /* Axlevel required to create rooms */
119         long c_maxmsglen;               /* Maximum message length           */
120         int c_min_workers;              /* Lower limit on number of threads */
121         int c_max_workers;              /* Upper limit on number of threads */
122         int c_pop3_port;                /* POP3 listener port (usually 110) */
123         int c_smtp_port;                /* SMTP listener port (usually 25)  */
124         int c_unused_1;                 /* Nothin' here anymore...          */
125         int c_aide_zap;                 /* Are Aides allowed to zap rooms?  */
126         int c_imap_port;                /* IMAP listener port (usually 143) */
127         time_t c_net_freq;              /* how often to run the networker   */
128         char c_disable_newu;            /* disable NEWU command             */
129         char c_aide_mailboxes;          /* give Aides access to mailboxes   */
130         char c_baseroom[ROOMNAMELEN];   /* Name of baseroom (Lobby)         */
131         char c_aideroom[ROOMNAMELEN];   /* Name of aideroom (Aide)          */
132 };
133
134 struct march {
135         struct march *next;
136         char march_name[ROOMNAMELEN];
137         unsigned int march_flags;
138         char march_floor;
139         char march_order;
140         unsigned int march_flags2;
141         int march_access;
142 };
143
144 #define NODENAME                config.c_nodename
145 #define FQDN                    config.c_fqdn
146 #define HUMANNODE               config.c_humannode
147 #define PHONENUM                config.c_phonenum
148 #define BBSUID                  config.c_bbsuid
149 #define CREATAIDE               config.c_creataide
150 #define REGISCALL               config.c_regiscall
151 #define TWITDETECT              config.c_twitdetect
152 #define TWITROOM                config.c_twitroom
153 #define RESTRICT_INTERNET       config.c_restrict
154
155 /* Defines the actual user record */
156  
157 struct usersupp {                       /* User record                      */
158         int version;                    /* Cit vers. which created this rec */
159         uid_t uid;                      /* Associate with a unix account?   */
160         char password[32];              /* password (for BBS-only users)    */
161         unsigned flags;                 /* See US_ flags below              */
162         long timescalled;               /* Total number of logins           */
163         long posted;                    /* Number of messages posted (ever) */
164         cit_uint8_t axlevel;            /* Access level                     */
165         long usernum;                   /* User number (never recycled)     */
166         time_t lastcall;                /* Last time the user called        */
167         int USuserpurge;                /* Purge time (in days) for user    */
168         char fullname[64];              /* Name for Citadel messages & mail */
169         cit_uint8_t USscreenwidth;      /* Screen width (for textmode users)*/
170         cit_uint8_t USscreenheight;     /* Screen height(for textmode users)*/
171 };
172
173
174 /*
175  * This is the control record for the message base... 
176  */
177 struct CitControl {
178         long MMhighest;                 /* highest message number in file   */
179         unsigned MMflags;               /* Global system flags              */
180         long MMnextuser;                /* highest user number on system    */
181         long MMnextroom;                /* highest room number on system    */
182         int version;                    /* Server-hosted upgrade level      */
183 };
184
185 /* Bits which may appear in CitControl.MMflags.  Note that these don't
186  * necessarily pertain to the message base -- it's just a good place to
187  * store any global flags.
188  */
189 #define MM_VALID        4               /* New users need validating        */
190
191 /*
192  * Room records
193  */
194 struct quickroom {
195         char QRname[ROOMNAMELEN];       /* Name of room                     */
196         char QRpasswd[10];              /* Only valid if it's a private rm  */
197         long QRroomaide;                /* User number of room aide         */
198         long QRhighest;                 /* Highest message NUMBER in room   */
199         time_t QRgen;                   /* Generation number of room        */
200         unsigned QRflags;               /* See flag values below            */
201         char QRdirname[15];             /* Directory name, if applicable    */
202         long QRinfo;                    /* Info file update relative to msgs*/
203         char QRfloor;                   /* Which floor this room is on      */
204         time_t QRmtime;                 /* Date/time of last post           */
205         struct ExpirePolicy QRep;       /* Message expiration policy        */
206         long QRnumber;                  /* Globally unique room number      */
207         char QRorder;                   /* Sort key for room listing order  */
208         unsigned QRflags2;              /* Additional flags                 */
209         int QRdefaultview;              /* How to display the contents      */
210 };
211
212 /* Private rooms are always flagged with QR_PRIVATE.  If neither QR_PASSWORDED
213  * or QR_GUESSNAME is set, then it is invitation-only.  Passworded rooms are
214  * flagged with both QR_PRIVATE and QR_PASSWORDED while guess-name rooms are
215  * flagged with both QR_PRIVATE and QR_GUESSNAME.  NEVER set all three flags.
216  */
217
218 /*
219  * Events which might show up in the Citadel Log
220  */
221 #define CL_CONNECT      8               /* Connect to server                */
222 #define CL_LOGIN        16              /* CLfullname logged in             */
223 #define CL_NEWUSER      32              /* CLfullname is a new user         */
224 #define CL_BADPW        64              /* Bad attempt at CLfullname's pw   */
225 #define CL_TERMINATE    128             /* Logout - proper termination      */
226 #define CL_DROPCARR     256             /* Logout - dropped carrier         */
227 #define CL_SLEEPING     512             /* Logout - sleeping                */
228 #define CL_PWCHANGE     1024            /* CLfullname changed passwords     */
229
230 /* Miscellaneous                                                            */
231
232 #define MES_NORMAL      65              /* Normal message                   */
233 #define MES_ANONONLY    66              /* "****" header                    */
234 #define MES_ANONOPT     67              /* "Anonymous" header               */
235
236 #define MES_ERROR       (-1)    /* Can't send message due to bad address   */
237 #define MES_LOCAL       0       /* Local message, do no network processing */
238 #define MES_INTERNET    1       /* Convert msg and send as Internet mail   */
239 #define MES_IGNET       2       /* Process recipient and send via Cit net  */
240
241 /****************************************************************************/
242
243 /*
244  * Floor record.  The floor number is implicit in its location in the file.
245  */
246 struct floor {
247         unsigned short f_flags;         /* flags */
248         char f_name[256];               /* name of floor */
249         int f_ref_count;                /* reference count */
250         struct ExpirePolicy f_ep;       /* default expiration policy */
251         };
252
253 #define F_INUSE         1               /* floor is in use */
254
255
256 /*
257  * Values used internally for function call returns, etc.
258  */
259
260 #define NEWREGISTER     0               /* new user to register */
261 #define REREGISTER      1               /* existing user reregistering */
262
263 #define READ_HEADER     2
264 #define READ_MSGBODY    3
265
266 /* commands we can send to the sttybbs() routine */
267 #define SB_NO_INTR      0               /* set to bbs mode, i/q disabled */
268 #define SB_YES_INTR     1               /* set to bbs mode, i/q enabled */
269 #define SB_SAVE         2               /* save settings */
270 #define SB_RESTORE      3               /* restore settings */
271 #define SB_LAST         4               /* redo the last command sent */
272
273 #define NEXT_KEY        15
274 #define STOP_KEY        3
275
276 /* server exit codes */
277 #define EXIT_NORMAL     0               /* server terminated normally */
278                                         /* 1 through 63 reserved for signals */
279 #define EXIT_NULL       64              /* EOF on server command input */
280
281 /* citadel.rc stuff */
282 #define RC_NO           0               /* always no */
283 #define RC_YES          1               /* always yes */
284 #define RC_DEFAULT      2               /* setting depends on user config */
285
286 /* keepalives */
287 enum {
288         KA_NO,                          /* no keepalives */
289         KA_YES,                         /* full keepalives */
290         KA_HALF                         /* half keepalives */
291 };
292
293 /* for <;G>oto and <;S>kip commands */
294 #define GF_GOTO         0               /* <;G>oto floor mode */
295 #define GF_SKIP         1               /* <;S>kip floor mode */
296 #define GF_ZAP          2               /* <;Z>ap floor mode */
297
298 /*
299  * MIME types used in Citadel for configuration stuff
300  */
301 #define SPOOLMIME       "application/x-citadel-delivery-list"
302 #define INTERNETCFG     "application/x-citadel-internet-config"
303 #define IGNETCFG        "application/x-citadel-ignet-config"
304 #define IGNETMAP        "application/x-citadel-ignet-map"
305 #define FILTERLIST      "application/x-citadel-filter-list"
306 #define SPAMSTRINGS     "application/x-citadel-spam-strings"
307
308 #define TRACE   lprintf(9, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
309
310 #ifndef LONG_MAX
311 #define LONG_MAX 2147483647L
312 #endif
313
314
315 /*
316  * Views
317  */
318 #define VIEW_BBS                0       /* Traditional Citadel BBS view */
319 #define VIEW_MAILBOX            1       /* Mailbox summary */
320 #define VIEW_ADDRESSBOOK        2       /* Address book view */
321
322 #ifdef __cplusplus
323 }
324 #endif
325
326 #ifdef tmpnam
327 #undef tmpnam
328 #endif
329 #define tmpnam(x)       CtdlTempFileName(__FILE__, __LINE__)
330
331 #ifdef tmpfile
332 #undef tmpfile
333 #endif
334 #define tmpfile()       CtdlTempFile()
335
336 #endif /* CITADEL_H */