Experimental utility ctdl3264 for database conversion (not finished)
authorArt Cancro <ajc@citadel.org>
Tue, 14 Feb 2023 14:36:05 +0000 (09:36 -0500)
committerArt Cancro <ajc@citadel.org>
Tue, 14 Feb 2023 14:36:05 +0000 (09:36 -0500)
citadel/.gitignore
citadel/Makefile
citadel/utils/ctdl3264.c [new file with mode: 0644]
citadel/utils/ctdl3264_prep.sh [new file with mode: 0755]

index 24b5eaad689693968986012f534dca65cd608e17..33640816c0569036de1131bdb61a3a881e470928 100644 (file)
@@ -30,3 +30,4 @@ netconfigs
 data
 package-version.txt
 core.*
+utils/ctdl3264_structs.h
index c89f92cc0aa6d115a38e8ffef2d8962b5edd6228..a5747326430f97cfeb68da3ed60532bb8619b30d 100644 (file)
@@ -11,7 +11,7 @@
 # config.mk is generated by ./configure
 include config.mk
 
-all := citserver setup ctdlmigrate sendcommand citmail chkpw chkpwd
+all := citserver setup ctdlmigrate sendcommand citmail chkpw chkpwd ctdl3264
 all: $(all)
 
 citserver: server/*.c server/modules/*/*.c config.mk server/*.h
@@ -38,6 +38,12 @@ chkpw: utils/chkpw.c utils/*.h server/*.h
 chkpwd: utils/chkpwd.c utils/auth.c utils/*.h server/*.h
        cc ${CFLAGS} ${LDFLAGS} utils/chkpwd.c utils/auth.c -lcrypt -o chkpwd
 
+ctdl3264: utils/ctdl3264.c utils/*.h server/*.h utils/ctdl3264_structs.h
+       cc ${CFLAGS} ${LDFLAGS} utils/ctdl3264.c -ldb -o ctdl3264
+
+utils/ctdl3264_structs.h: server/server.h utils/ctdl3264_prep.sh
+       utils/ctdl3264_prep.sh
+
 config.mk: configure
        ./configure
 
diff --git a/citadel/utils/ctdl3264.c b/citadel/utils/ctdl3264.c
new file mode 100644 (file)
index 0000000..8d51e9c
--- /dev/null
@@ -0,0 +1,41 @@
+// Attempt to convert your database from 32-bit to 64-bit.
+// Don't run this.  It doesn't work and if you try to run it you will immediately die.
+//
+// Copyright (c) 1987-2022 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.
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netdb.h>
+#include <string.h>
+#include <pwd.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <limits.h>
+#include <libcitadel.h>
+#include "../server/sysdep.h"
+#include "../server/citadel_defs.h"
+#include "../server/server.h"
+#include "../server/citadel_dirs.h"
+#include "ctdl3264_structs.h"
+
+
+int main(int argc, char **argv) {
+
+       if (sizeof(void *) != 8) {
+               fprintf(stderr, "%s: this is a %ld-bit system.\n", argv[0], sizeof(void *)*8);
+               fprintf(stderr, "%s: you must run this on a 64-bit system, onto which a 32-bit database has been copied.\n", argv[0]);
+               exit(1);
+       }
+
+
+       exit(0);
+}
diff --git a/citadel/utils/ctdl3264_prep.sh b/citadel/utils/ctdl3264_prep.sh
new file mode 100755 (executable)
index 0000000..f68a0d9
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+SERVER_H=server/server.h
+
+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/"int "/"int32_t "/g \
+       | sed s/"long "/"int32_t "/g \
+       | sed s/"time_t "/"int32_t "/g
+
+}
+
+(
+       convert_struct "ctdluser"
+       convert_struct "ctdlroom"
+       convert_struct "ExpirePolicy"
+       convert_struct "floor"
+
+) >utils/ctdl3264_structs.h