From ead09e9d6cc6e428d319daa5dbff1b7c4903616c Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 14 Feb 2023 09:36:05 -0500 Subject: [PATCH] Experimental utility ctdl3264 for database conversion (not finished) --- citadel/.gitignore | 1 + citadel/Makefile | 8 ++++++- citadel/utils/ctdl3264.c | 41 ++++++++++++++++++++++++++++++++++ citadel/utils/ctdl3264_prep.sh | 21 +++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 citadel/utils/ctdl3264.c create mode 100755 citadel/utils/ctdl3264_prep.sh diff --git a/citadel/.gitignore b/citadel/.gitignore index 24b5eaad6..33640816c 100644 --- a/citadel/.gitignore +++ b/citadel/.gitignore @@ -30,3 +30,4 @@ netconfigs data package-version.txt core.* +utils/ctdl3264_structs.h diff --git a/citadel/Makefile b/citadel/Makefile index c89f92cc0..a57473264 100644 --- a/citadel/Makefile +++ b/citadel/Makefile @@ -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 index 000000000..8d51e9c06 --- /dev/null +++ b/citadel/utils/ctdl3264.c @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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 index 000000000..f68a0d988 --- /dev/null +++ b/citadel/utils/ctdl3264_prep.sh @@ -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 -- 2.39.2