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