63919c8af4c24ee0d185bcea2f886db226242584
[citadel.git] / citadel / server / citadel.h
1 // Main Citadel header file
2 //
3 // Copyright (c) 1987-2022 by the citadel.org team
4 //
5 // This program is open source software.  Use, duplication, or disclosure
6 // is subject to the terms of the GNU General Public License, version 3.
7 // The program is distributed without any warranty, expressed or implied.
8
9 #ifndef CITADEL_H
10 #define CITADEL_H
11
12 // Suppress these compiler warnings
13 #pragma GCC diagnostic ignored "-Wcast-qual"
14 #pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
15 #pragma GCC diagnostic ignored "-Wformat-truncation"
16
17 #include "sysdep.h"
18 #include <limits.h>
19 #include "sysconfig.h"
20 #include "typesize.h"
21 #include "ipcdef.h"
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 // Text description of this software
28 // (We used to define this ourselves, but why bother when the build tools do it for us?)
29 #define CITADEL PACKAGE_STRING
30
31 #define REV_LEVEL 951           // This version
32 #define REV_MIN         591             // Oldest compatible database
33 #define EXPORT_REV_MIN  931             // Oldest compatible export files
34 #define LIBCITADEL_MIN  951             // Minimum required version of libcitadel
35 #define SERVER_TYPE     0               // zero for stock Citadel; other developers please obtain SERVER_TYPE codes for your implementations
36
37 #ifdef LIBCITADEL_VERSION_NUMBER
38 #if LIBCITADEL_VERSION_NUMBER < LIBCITADEL_MIN
39 #error libcitadel is too old.  Please upgrade it before continuing.
40 #endif
41 #endif
42
43 // This is the user name and password for the default administrator account
44 // that is created when Citadel Server is started with an empty database.
45 #define DEFAULT_ADMIN_USERNAME  "admin"
46 #define DEFAULT_ADMIN_PASSWORD  "citadel"
47
48 // Various length constants
49 #define ROOMNAMELEN     128             // The size of a roomname string
50 #define USERNAME_SIZE   64              // The size of a username string
51 #define MAX_EDITORS     5               // number of external editors supported ; must be at least 1
52
53 // Message expiration policy stuff
54 typedef struct ExpirePolicy ExpirePolicy;
55 struct ExpirePolicy {
56         int expire_mode;
57         int expire_value;
58 };
59
60 #define EXPIRE_NEXTLEVEL        0       // Inherit expiration policy
61 #define EXPIRE_MANUAL           1       // Don't expire messages at all
62 #define EXPIRE_NUMMSGS          2       // Keep only latest n messages
63 #define EXPIRE_AGE              3       // Expire messages after n days
64
65 // User records.
66 typedef struct ctdluser ctdluser;
67 struct ctdluser {                       // User record
68         int version;                    // Citadel version which created this record
69         uid_t uid;                      // Associate with a unix account?
70         char password[32];              // password
71         unsigned flags;                 // See US_ flags below
72         long timescalled;               // Total number of logins
73         long posted;                    // Number of messages ever submitted
74         cit_uint8_t axlevel;            // Access level
75         long usernum;                   // User number (never recycled)
76         time_t lastcall;                // Date/time of most recent login
77         int USuserpurge;                // Purge time (in days) for user
78         char fullname[64];              // Display name (primary identifier)
79         long msgnum_bio;                // msgnum of user's profile (bio)
80         long msgnum_pic;                // msgnum of user's avatar (photo)
81         char emailaddrs[512];           // Internet email addresses
82         long msgnum_inboxrules;         // msgnum of user's inbox filtering rules
83         long lastproc_inboxrules;       // msgnum of last message filtered
84 };
85
86 // Bits which may appear in MMflags.
87 #define MM_VALID        4               // New users need validating
88
89 // Room records.
90 typedef struct ctdlroom ctdlroom;
91 struct ctdlroom {
92         char QRname[ROOMNAMELEN];       // Name of room
93         char QRpasswd[10];              // Only valid if it's a private rm
94         long QRroomaide;                // User number of room aide
95         long QRhighest;                 // Highest message NUMBER in room
96         time_t QRgen;                   // Generation number of room
97         unsigned QRflags;               // See flag values below
98         char QRdirname[15];             // Directory name, if applicable
99         long msgnum_info;               // msgnum of room banner (info file)
100         char QRfloor;                   // Which floor this room is on
101         time_t QRmtime;                 // Date/time of last post
102         struct ExpirePolicy QRep;       // Message expiration policy
103         long QRnumber;                  // Globally unique room number
104         char QRorder;                   // Sort key for room listing order
105         unsigned QRflags2;              // Additional flags
106         int QRdefaultview;              // How to display the contents
107         long msgnum_pic;                // msgnum of room picture or icon
108 };
109
110 // Private rooms are always flagged with QR_PRIVATE.  If neither QR_PASSWORDED
111 // or QR_GUESSNAME is set, then it is invitation-only.  Passworded rooms are
112 // flagged with both QR_PRIVATE and QR_PASSWORDED while guess-name rooms are
113 // flagged with both QR_PRIVATE and QR_GUESSNAME.  NEVER set all three flags.
114
115 // Miscellaneous
116 #define MES_NORMAL      65              // Normal message
117 #define MES_ANONONLY    66              // "****" header
118 #define MES_ANONOPT     67              // "Anonymous" header
119
120 // Floor record.  The floor number is implicit in its location in the file.
121 typedef struct floor floor;
122 struct floor {
123         unsigned short f_flags;         // flags
124         char f_name[256];               // name of floor
125         int f_ref_count;                // reference count
126         struct ExpirePolicy f_ep;       // default expiration policy
127 };
128
129 #define F_INUSE         1               // floor is in use
130
131 // Values used internally for function call returns, etc.
132 #define NEWREGISTER     0               // new user to register
133 #define REREGISTER      1               // existing user reregistering
134
135 // number of items which may be handled by the CONF command
136 #define NUM_CONFIGS 71
137
138 #define TRACE   syslog(LOG_DEBUG, "\033[7m  Checkpoint: %s : %d  \033[0m", __FILE__, __LINE__)
139
140 #ifndef LONG_MAX
141 #define LONG_MAX 2147483647L
142 #endif
143
144 // Authentication modes
145 #define AUTHMODE_NATIVE         0       // Native (self-contained or "black box")
146 #define AUTHMODE_HOST           1       // Authenticate against the host OS user database
147 #define AUTHMODE_LDAP           2       // Authenticate using LDAP server with POSIX schema
148 #define AUTHMODE_LDAP_AD        3       // Authenticate using LDAP server with Active Directory schema
149
150 #ifdef __cplusplus
151 }
152 #endif
153
154 #endif // CITADEL_H