void cdb_compact(void);
-/*
- * 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;
-};
-
int CheckIfAlreadySeen(StrBuf *guid);
#endif /* DATABASE_H */
// 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
-struct MetaData {
// 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
char meta_content_type[64]; // Cached MIME content-type
};
+// 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
// Walk through the database, calling convert functions as we go and clearing buffers before each call.
while (out_key.size = 0, out_data.size = 0, (ret = dbcp->get(dbcp, &in_key, &in_data, DB_NEXT)) == 0) {
- // FIXME handle compressed records here
+ // Do we need to decompress?
+ static int32_t magic = COMPRESS_MAGIC;
+ if ( (in_data.size >= sizeof(magic)) && (!memcmp(in_data.data, &magic, sizeof(magic))) ) {
+ printf("\033[31m\033[1m COMPRESSED \033[0m\n");
+ // FIXME do the decompression
+ }
// Call the convert function registered to this table
convert_functions[which_cdb](which_cdb, &in_key, &in_data, &out_key, &out_data);
SERVER_H=server/server.h
# Generate the "32-bit" versions of these structures.
-# Note that this is specifically converting "32-bit to 64-bit" -- NOT "any-to-any"
+# Note that this is specifically for converting "32-bit to 64-bit" -- NOT "any-to-any"
convert_struct() {
start_line=$(cat ${SERVER_H} | egrep -n "^struct $1 {" | cut -d: -f1)
tail +${start_line} ${SERVER_H} | sed '/};/q' \
| sed s/"^struct $1 {"/"struct ${1}_32 {"/g \
| sed s/"long "/"int32_t "/g \
| sed s/"time_t "/"int32_t "/g \
+ | sed s/"size_t "/"int32_t "/g \
| sed s/"struct ExpirePolicy "/"struct ExpirePolicy_32 "/g
echo ''
convert_struct "floor"
convert_struct "visit"
convert_struct "MetaData"
+ convert_struct "CtdlCompressHeader"
) >utils/ctdl3264_structs.h