]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/server.h
Assert that eMessageText MUST be serialized last.
[citadel.git] / citadel / server / server.h
index d0a4cf8f647c85623d3ea168b3393e9e9290eab8..8d1f7d0ff3bbf99c93e9bfa5895d407dc53e286b 100644 (file)
@@ -1,6 +1,6 @@
 // Data types for the Citadel Server
 //
-// Copyright (c) 1987-2023 by the citadel.org team
+// Copyright (c) 1987-2024 by the citadel.org team
 //
 // This program is open source software.  Use, duplication, or disclosure
 // is subject to the terms of the GNU General Public License, version 3.
@@ -68,29 +68,48 @@ struct ExpressMessage {
 
 // Row being stored or fetched in the database
 struct cdbdata {
-       size_t len;
-       char *ptr;
+       size_t len;                     // size of datum pointed to by ptr
+       char *ptr;                      // datum
+};
+
+
+// Row being fetched from the database, both key and value are returned
+struct cdbkeyval {
+       struct cdbdata key;             // size and pointer to key
+       struct cdbdata val;             // size and pointer to value
 };
 
 
 // Defines the relationship of a user to a particular room
+// NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
+// NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
 struct visit {
-       long v_roomnum;
-       long v_roomgen;
-       long v_usernum;
+       long v_roomnum;         //
+       long v_roomgen;         // The first three fields , sizeof(long)*3 , are the index format.
+       long v_usernum;         //
        long v_lastseen;
-       unsigned int v_flags;
+       unsigned v_flags;
        char v_seen[SIZ];
        char v_answered[SIZ];
        int v_view;
 };
 
 
+// This is the db index format for "visit" records, which describe the relationship between one user and one room.
+struct visit_index {
+       long iRoomID;
+       long iRoomGen;
+       long iUserID;
+};
+
+
 // Supplementary data for a message on disk
 // These are kept separate from the message itself for one of two reasons:
 // 1. Either their values may change at some point after initial save, or
 // 2. They are merely caches of data which exist somewhere else, for speed.
 // DO NOT PUT BIG DATA IN HERE ... we need this struct to be tiny for lots of quick r/w
+// NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
+// NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
 struct MetaData {
        long meta_msgnum;               // Message number in *local* message base
        int meta_refcount;              // Number of rooms pointing to this msg
@@ -108,29 +127,24 @@ struct arcq {
 };
 
 
-// Serialization routines use this struct to return a pointer and a length
-struct ser_ret {
-       size_t len;
-       unsigned char *ser;
-};
-
-
 // The S_USETABLE database is used in several modules now, so we define its format here.
 struct UseTable {
-       char ut_msgid[SIZ];
-       time_t ut_timestamp;
+       int hash;
+       time_t timestamp;
 };
 
 
 // User records.
+// NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
+// NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
 typedef struct ctdluser ctdluser;
 struct ctdluser {                      // User record
        int version;                    // Citadel version which created this record
        uid_t uid;                      // Associate with a unix account?
        char password[32];              // password
        unsigned flags;                 // See US_ flags below
-       long timescalled;               // Total number of logins
-       long posted;                    // Number of messages ever submitted
+       long unused1;
+       long unused2;
        cit_uint8_t axlevel;            // Access level
        long usernum;                   // User number (never recycled)
        time_t lastcall;                // Date/time of most recent login
@@ -145,6 +159,8 @@ struct ctdluser {                   // User record
 
 
 // Message expiration policy stuff
+// NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
+// NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
 typedef struct ExpirePolicy ExpirePolicy;
 struct ExpirePolicy {
        int expire_mode;
@@ -153,6 +169,8 @@ struct ExpirePolicy {
 
 
 // Room records.
+// NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
+// NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
 struct ctdlroom {
        char QRname[ROOMNAMELEN];       // Name of room
        char QRpasswd[10];              // Only valid if it's a private rm
@@ -174,6 +192,8 @@ struct ctdlroom {
 
 
 // Floor record.  The floor number is implicit in its location in the file.
+// NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
+// NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
 struct floor {
        unsigned short f_flags;         // flags
        char f_name[256];               // name of floor
@@ -182,4 +202,20 @@ struct floor {
 };
 
 
+// Database records beginning with this magic number are assumed to
+// be compressed.  In the event that a database record actually begins with
+// this magic number, we *must* compress it whether we want to or not,
+// because the fetch function will try to uncompress it anyway.
+// 
+// (No need to #ifdef this stuff; it compiles ok even if zlib is not present
+// and doesn't declare anything so it won't bloat the code)
+#define COMPRESS_MAGIC 0xc0ffeeee
+
+struct CtdlCompressHeader {
+       int magic;
+       size_t uncompressed_len;
+       size_t compressed_len;
+};
+
+
 #endif // SERVER_H