]> code.citadel.org Git - citadel.git/blob - citadel/server/server.h
Remove preprocessor tests for OpenSSL. It's a requirement.
[citadel.git] / citadel / server / server.h
1 // Data types for the Citadel Server
2 //
3 // Copyright (c) 1987-2024 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
8 #ifndef SERVER_H
9 #define SERVER_H
10
11 #ifdef __GNUC__
12 #define INLINE __inline__
13 #else
14 #define INLINE
15 #endif
16
17 #include "citadel_defs.h"
18 #define OPENSSL_NO_KRB5                 // work around redhat b0rken ssl headers
19 #include <openssl/ssl.h>
20
21
22 // New format for a message in memory
23 struct CtdlMessage {
24         int cm_magic;                   // Self-check (NOT SAVED TO DISK)
25         char cm_anon_type;              // Anonymous or author-visible
26         char cm_format_type;            // Format type
27         char *cm_fields[256];           // Data fields
28         long cm_lengths[256];           // size of datafields
29         unsigned int cm_flags;          // How to handle (NOT SAVED TO DISK)
30 };
31
32
33 // Data structure returned by validate_recipients()
34 struct recptypes {
35         int recptypes_magic;
36         int num_local;
37         int num_internet;
38         int num_room;
39         int num_error;
40         char *errormsg;
41         char *recp_local;
42         char *recp_internet;
43         char *recp_room;
44         char *recp_orgroom;
45         char *display_recp;
46         char *bounce_to;
47         char *envelope_from;
48         char *sending_room;
49 };
50
51 extern int ScheduledShutdown;
52 extern uid_t ctdluid;
53 extern int sanity_diag_mode;
54
55
56 // Instant message in transit on the system (not used in the database)
57 struct ExpressMessage {
58         struct ExpressMessage *next;
59         time_t timestamp;       // When this message was sent
60         unsigned flags;         // Special instructions
61         char sender[256];       // Name of sending user
62         char sender_email[256]; // Email or JID of sending user
63         char *text;             // Message text (if applicable)
64 };
65
66
67 // Row being stored or fetched in the database
68 struct cdbdata {
69         size_t len;                     // size of datum pointed to by ptr
70         char *ptr;                      // datum
71 };
72
73
74 // Row being fetched from the database, both key and value are returned
75 struct cdbkeyval {
76         struct cdbdata key;             // size and pointer to key
77         struct cdbdata val;             // size and pointer to value
78 };
79
80
81 // Defines the relationship of a user to a particular room
82 // NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
83 // NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
84 struct visit {
85         long v_roomnum;         //
86         long v_roomgen;         // The first three fields , sizeof(long)*3 , are the index format.
87         long v_usernum;         //
88         long v_lastseen;
89         unsigned v_flags;
90         char v_seen[SIZ];
91         char v_answered[SIZ];
92         int v_view;
93 };
94
95
96 // This is the db index format for "visit" records, which describe the relationship between one user and one room.
97 struct visit_index {
98         long iRoomID;
99         long iRoomGen;
100         long iUserID;
101 };
102
103
104 // Supplementary data for a message on disk
105 // These are kept separate from the message itself for one of two reasons:
106 // 1. Either their values may change at some point after initial save, or
107 // 2. They are merely caches of data which exist somewhere else, for speed.
108 // DO NOT PUT BIG DATA IN HERE ... we need this struct to be tiny for lots of quick r/w
109 // NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
110 // NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
111 struct MetaData {
112         long meta_msgnum;               // Message number in *local* message base
113         int meta_refcount;              // Number of rooms pointing to this msg
114         char meta_content_type[64];     // Cached MIME content-type
115         long meta_rfc822_length;        // Cache of RFC822-translated msg length
116 };
117
118
119 // Calls to AdjRefCount() are queued and deferred, so the user doesn't
120 // have to wait for various disk-intensive operations to complete synchronously.
121 // This is the record format.
122 struct arcq {
123         long arcq_msgnum;               // Message number being adjusted
124         int arcq_delta;                 // Adjustment ( usually 1 or -1 )
125 };
126
127
128 // The S_USETABLE database is used in several modules now, so we define its format here.
129 struct UseTable {
130         int hash;
131         time_t timestamp;
132 };
133
134
135 // User records.
136 // NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
137 // NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
138 typedef struct ctdluser ctdluser;
139 struct ctdluser {                       // User record
140         int version;                    // Citadel version which created this record
141         uid_t uid;                      // Associate with a unix account?
142         char password[32];              // password
143         unsigned flags;                 // See US_ flags below
144         long unused1;
145         long unused2;
146         cit_uint8_t axlevel;            // Access level
147         long usernum;                   // User number (never recycled)
148         time_t lastcall;                // Date/time of most recent login
149         int USuserpurge;                // Purge time (in days) for user
150         char fullname[64];              // Display name (primary identifier)
151         long msgnum_bio;                // msgnum of user's profile (bio)
152         long msgnum_pic;                // msgnum of user's avatar (photo)
153         char emailaddrs[512];           // Internet email addresses
154         long msgnum_inboxrules;         // msgnum of user's inbox filtering rules
155         long lastproc_inboxrules;       // msgnum of last message filtered
156 };
157
158
159 // Message expiration policy stuff
160 // NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
161 // NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
162 typedef struct ExpirePolicy ExpirePolicy;
163 struct ExpirePolicy {
164         int expire_mode;
165         int expire_value;
166 };
167
168
169 // Room records.
170 // NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
171 // NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
172 struct ctdlroom {
173         char QRname[ROOMNAMELEN];       // Name of room
174         char QRpasswd[10];              // Only valid if it's a private rm
175         long QRroomaide;                // User number of room aide
176         long QRhighest;                 // Highest message NUMBER in room
177         time_t QRgen;                   // Generation number of room
178         unsigned QRflags;               // See flag values below
179         char QRdirname[15];             // Directory name, if applicable
180         long msgnum_info;               // msgnum of room banner (info file)
181         char QRfloor;                   // Which floor this room is on
182         time_t QRmtime;                 // Date/time of last post
183         struct ExpirePolicy QRep;       // Message expiration policy
184         long QRnumber;                  // Globally unique room number
185         char QRorder;                   // Sort key for room listing order
186         unsigned QRflags2;              // Additional flags
187         int QRdefaultview;              // How to display the contents
188         long msgnum_pic;                // msgnum of room picture or icon
189 };
190
191
192 // Floor record.  The floor number is implicit in its location in the file.
193 // NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
194 // NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
195 struct floor {
196         unsigned short f_flags;         // flags
197         char f_name[256];               // name of floor
198         int f_ref_count;                // reference count
199         struct ExpirePolicy f_ep;       // default expiration policy
200 };
201
202
203 // Database records beginning with this magic number are assumed to
204 // be compressed.  In the event that a database record actually begins with
205 // this magic number, we *must* compress it whether we want to or not,
206 // because the fetch function will try to uncompress it anyway.
207 // 
208 // (No need to #ifdef this stuff; it compiles ok even if zlib is not present
209 // and doesn't declare anything so it won't bloat the code)
210 #define COMPRESS_MAGIC  0xc0ffeeee
211
212 struct CtdlCompressHeader {
213         int magic;
214         size_t uncompressed_len;
215         size_t compressed_len;
216 };
217
218
219 #endif // SERVER_H