1 // Data types for the Citadel Server
3 // Copyright (c) 1987-2023 by the citadel.org team
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.
12 #define INLINE __inline__
17 #include "citadel_defs.h"
19 #define OPENSSL_NO_KRB5 // work around redhat b0rken ssl headers
20 #include <openssl/ssl.h>
24 // New format for a message in memory
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)
35 // Data structure returned by validate_recipients()
53 extern int ScheduledShutdown;
55 extern int sanity_diag_mode;
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)
69 // Row being stored or fetched in the database
71 size_t len; // size of datum pointed to by ptr
73 int cdbfree_must_free_ptr; // nonzero if cdb_free() is expected to free(ptr)
77 // Defines the relationship of a user to a particular room
78 // NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
79 // NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
82 long v_roomgen; // The first three fields , sizeof(long)*3 , are the index format.
92 // This is the db index format for "visit" records, which describe the relationship between one user and one room.
100 // Supplementary data for a message on disk
101 // These are kept separate from the message itself for one of two reasons:
102 // 1. Either their values may change at some point after initial save, or
103 // 2. They are merely caches of data which exist somewhere else, for speed.
104 // DO NOT PUT BIG DATA IN HERE ... we need this struct to be tiny for lots of quick r/w
105 // NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
106 // NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
108 long meta_msgnum; // Message number in *local* message base
109 int meta_refcount; // Number of rooms pointing to this msg
110 char meta_content_type[64]; // Cached MIME content-type
111 long meta_rfc822_length; // Cache of RFC822-translated msg length
115 // Calls to AdjRefCount() are queued and deferred, so the user doesn't
116 // have to wait for various disk-intensive operations to complete synchronously.
117 // This is the record format.
119 long arcq_msgnum; // Message number being adjusted
120 int arcq_delta; // Adjustment ( usually 1 or -1 )
124 // Serialization routines use this struct to return a pointer and a length
131 // The S_USETABLE database is used in several modules now, so we define its format here.
139 // NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
140 // NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
141 typedef struct ctdluser ctdluser;
142 struct ctdluser { // User record
143 int version; // Citadel version which created this record
144 uid_t uid; // Associate with a unix account?
145 char password[32]; // password
146 unsigned flags; // See US_ flags below
149 cit_uint8_t axlevel; // Access level
150 long usernum; // User number (never recycled)
151 time_t lastcall; // Date/time of most recent login
152 int USuserpurge; // Purge time (in days) for user
153 char fullname[64]; // Display name (primary identifier)
154 long msgnum_bio; // msgnum of user's profile (bio)
155 long msgnum_pic; // msgnum of user's avatar (photo)
156 char emailaddrs[512]; // Internet email addresses
157 long msgnum_inboxrules; // msgnum of user's inbox filtering rules
158 long lastproc_inboxrules; // msgnum of last message filtered
162 // Message expiration policy stuff
163 // NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
164 // NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
165 typedef struct ExpirePolicy ExpirePolicy;
166 struct ExpirePolicy {
173 // NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
174 // NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
176 char QRname[ROOMNAMELEN]; // Name of room
177 char QRpasswd[10]; // Only valid if it's a private rm
178 long QRroomaide; // User number of room aide
179 long QRhighest; // Highest message NUMBER in room
180 time_t QRgen; // Generation number of room
181 unsigned QRflags; // See flag values below
182 char QRdirname[15]; // Directory name, if applicable
183 long msgnum_info; // msgnum of room banner (info file)
184 char QRfloor; // Which floor this room is on
185 time_t QRmtime; // Date/time of last post
186 struct ExpirePolicy QRep; // Message expiration policy
187 long QRnumber; // Globally unique room number
188 char QRorder; // Sort key for room listing order
189 unsigned QRflags2; // Additional flags
190 int QRdefaultview; // How to display the contents
191 long msgnum_pic; // msgnum of room picture or icon
195 // Floor record. The floor number is implicit in its location in the file.
196 // NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
197 // NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
199 unsigned short f_flags; // flags
200 char f_name[256]; // name of floor
201 int f_ref_count; // reference count
202 struct ExpirePolicy f_ep; // default expiration policy
206 // Database records beginning with this magic number are assumed to
207 // be compressed. In the event that a database record actually begins with
208 // this magic number, we *must* compress it whether we want to or not,
209 // because the fetch function will try to uncompress it anyway.
211 // (No need to #ifdef this stuff; it compiles ok even if zlib is not present
212 // and doesn't declare anything so it won't bloat the code)
213 #define COMPRESS_MAGIC 0xc0ffeeee
215 struct CtdlCompressHeader {
217 size_t uncompressed_len;
218 size_t compressed_len;