moved more defs from server.h to citadel_defs.h
[citadel.git] / citadel / server / server.h
1 // Data types for the Citadel Server
2 //
3 // Copyright (c) 1987-2023 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 #ifdef HAVE_OPENSSL
19 #define OPENSSL_NO_KRB5                 // work around redhat b0rken ssl headers
20 #include <openssl/ssl.h>
21 #endif
22
23
24 // New format for a message in memory
25 struct CtdlMessage {
26         int cm_magic;                   // Self-check (NOT SAVED TO DISK)
27         char cm_anon_type;              // Anonymous or author-visible
28         char cm_format_type;            // Format type
29         char *cm_fields[256];           // Data fields
30         long cm_lengths[256];           // size of datafields
31         unsigned int cm_flags;          // How to handle (NOT SAVED TO DISK)
32 };
33
34
35 // Data structure returned by validate_recipients()
36 struct recptypes {
37         int recptypes_magic;
38         int num_local;
39         int num_internet;
40         int num_room;
41         int num_error;
42         char *errormsg;
43         char *recp_local;
44         char *recp_internet;
45         char *recp_room;
46         char *recp_orgroom;
47         char *display_recp;
48         char *bounce_to;
49         char *envelope_from;
50         char *sending_room;
51 };
52
53 extern int ScheduledShutdown;
54 extern uid_t ctdluid;
55 extern int sanity_diag_mode;
56
57
58 // Instant message in transit on the system (not used in the database)
59 struct ExpressMessage {
60         struct ExpressMessage *next;
61         time_t timestamp;       // When this message was sent
62         unsigned flags;         // Special instructions
63         char sender[256];       // Name of sending user
64         char sender_email[256]; // Email or JID of sending user
65         char *text;             // Message text (if applicable)
66 };
67
68
69 // Row being stored or fetched in the database
70 struct cdbdata {
71         size_t len;
72         char *ptr;
73 };
74
75
76 // Defines the relationship of a user to a particular room
77 typedef struct __visit {
78         long v_roomnum;
79         long v_roomgen;
80         long v_usernum;
81         long v_lastseen;
82         unsigned int v_flags;
83         char v_seen[SIZ];
84         char v_answered[SIZ];
85         int v_view;
86 } visit;
87
88
89 // Supplementary data for a message on disk
90 // These are kept separate from the message itself for one of two reasons:
91 // 1. Either their values may change at some point after initial save, or
92 // 2. They are merely caches of data which exist somewhere else, for speed.
93 // DO NOT PUT BIG DATA IN HERE ... we need this struct to be tiny for lots of quick r/w
94 struct MetaData {
95         long meta_msgnum;               // Message number in *local* message base
96         int meta_refcount;              // Number of rooms pointing to this msg
97         char meta_content_type[64];     // Cached MIME content-type
98         long meta_rfc822_length;        // Cache of RFC822-translated msg length
99 };
100
101
102 // Calls to AdjRefCount() are queued and deferred, so the user doesn't
103 // have to wait for various disk-intensive operations to complete synchronously.
104 // This is the record format.
105 struct arcq {
106         long arcq_msgnum;               // Message number being adjusted
107         int arcq_delta;                 // Adjustment ( usually 1 or -1 )
108 };
109
110
111 // Serialization routines use this struct to return a pointer and a length
112 struct ser_ret {
113         size_t len;
114         unsigned char *ser;
115 };
116
117
118 // The S_USETABLE database is used in several modules now, so we define its format here.
119 struct UseTable {
120         char ut_msgid[SIZ];
121         time_t ut_timestamp;
122 };
123
124
125 // User records.
126 typedef struct ctdluser ctdluser;
127 struct ctdluser {                       // User record
128         int version;                    // Citadel version which created this record
129         uid_t uid;                      // Associate with a unix account?
130         char password[32];              // password
131         unsigned flags;                 // See US_ flags below
132         long timescalled;               // Total number of logins
133         long posted;                    // Number of messages ever submitted
134         cit_uint8_t axlevel;            // Access level
135         long usernum;                   // User number (never recycled)
136         time_t lastcall;                // Date/time of most recent login
137         int USuserpurge;                // Purge time (in days) for user
138         char fullname[64];              // Display name (primary identifier)
139         long msgnum_bio;                // msgnum of user's profile (bio)
140         long msgnum_pic;                // msgnum of user's avatar (photo)
141         char emailaddrs[512];           // Internet email addresses
142         long msgnum_inboxrules;         // msgnum of user's inbox filtering rules
143         long lastproc_inboxrules;       // msgnum of last message filtered
144 };
145
146
147 // Message expiration policy stuff
148 typedef struct ExpirePolicy ExpirePolicy;
149 struct ExpirePolicy {
150         int expire_mode;
151         int expire_value;
152 };
153
154
155 // Room records.
156 struct ctdlroom {
157         char QRname[ROOMNAMELEN];       // Name of room
158         char QRpasswd[10];              // Only valid if it's a private rm
159         long QRroomaide;                // User number of room aide
160         long QRhighest;                 // Highest message NUMBER in room
161         time_t QRgen;                   // Generation number of room
162         unsigned QRflags;               // See flag values below
163         char QRdirname[15];             // Directory name, if applicable
164         long msgnum_info;               // msgnum of room banner (info file)
165         char QRfloor;                   // Which floor this room is on
166         time_t QRmtime;                 // Date/time of last post
167         struct ExpirePolicy QRep;       // Message expiration policy
168         long QRnumber;                  // Globally unique room number
169         char QRorder;                   // Sort key for room listing order
170         unsigned QRflags2;              // Additional flags
171         int QRdefaultview;              // How to display the contents
172         long msgnum_pic;                // msgnum of room picture or icon
173 };
174
175
176 // Floor record.  The floor number is implicit in its location in the file.
177 struct floor {
178         unsigned short f_flags;         // flags
179         char f_name[256];               // name of floor
180         int f_ref_count;                // reference count
181         struct ExpirePolicy f_ep;       // default expiration policy
182 };
183
184
185 #endif // SERVER_H