From b3fc03bae6bc44fafdf634c11896d3e19bc1b8d9 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 16 Oct 2024 22:50:06 +0100 Subject: [PATCH] Delete unused module code --- libraries/liblmdb/module.c | 106 ------------------------------------- libraries/liblmdb/module.h | 17 ------ 2 files changed, 123 deletions(-) delete mode 100644 libraries/liblmdb/module.c delete mode 100644 libraries/liblmdb/module.h diff --git a/libraries/liblmdb/module.c b/libraries/liblmdb/module.c deleted file mode 100644 index 16fefa96c0..0000000000 --- a/libraries/liblmdb/module.c +++ /dev/null @@ -1,106 +0,0 @@ -/* module.c - helper for dynamically loading crypto module */ -/* - * Copyright 2020-2021 Howard Chu, Symas Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted only as authorized by the Symas - * Dual-Use License. - * - * A copy of this license is available in the file LICENSE in the - * source distribution. - */ -#ifdef _WIN32 -#include -#else -#include -#endif - -#include -#include - -#include "lmdb.h" -#include "module.h" - -void *mlm_load(const char *file, const char *name, MDB_crypto_funcs **mcf_ptr, char **errmsg) -{ - MDB_crypto_hooks *hookfunc; - void *ret = NULL; - if (!name) - name = "MDB_crypto"; - -#ifdef _WIN32 - { - HINSTANCE mlm = LoadLibrary(file); - if (mlm) { - hookfunc = GetProcAddress(mlm, name); - if (hookfunc) - *mcf_ptr = hookfunc(); - else { - *errmsg = "Crypto hook function not found"; - FreeLibrary(mlm); - mlm = NULL; - } - } else { - *errmsg = GetLastError(); - } - ret = (void *)mlm; - } -#else - { - void *mlm = dlopen(file, RTLD_NOW); - if (mlm) { - hookfunc = dlsym(mlm, name); - if (hookfunc) - *mcf_ptr = hookfunc(); - else { - *errmsg = "Crypto hook function not found"; - dlclose(mlm); - mlm = NULL; - } - } else { - *errmsg = dlerror(); - } - ret = mlm; - } -#endif - return ret; -} - -void mlm_unload(void *mlm) -{ -#ifdef _WIN32 - FreeLibrary((HINSTANCE)mlm); -#else - dlclose(mlm); -#endif -} - -void mlm_setup0(MDB_env *env, MDB_crypto_funcs *cf, const char *password) -{ - MDB_val enckey = {0}; - if (cf->mcf_sumfunc) { - mdb_env_set_checksum(env, cf->mcf_sumfunc, cf->mcf_sumsize); - } - if (cf->mcf_encfunc && password) { - char keybuf[2048]; - enckey.mv_data = keybuf; - enckey.mv_size = cf->mcf_keysize; - if (cf->mcf_str2key) - cf->mcf_str2key(password, &enckey); - else - strncpy(enckey.mv_data, password, enckey.mv_size); - mdb_env_set_encrypt(env, cf->mcf_encfunc, &enckey, cf->mcf_esumsize); - memset(enckey.mv_data, 0, enckey.mv_size); - } -} - -void *mlm_setup(MDB_env *env, const char *file, const char *password, char **errmsg) -{ - MDB_crypto_funcs *cf; - void *mlm = mlm_load(file, NULL, &cf, errmsg); - if (mlm) { - mlm_setup0(env, cf, password); - } - return mlm; -} diff --git a/libraries/liblmdb/module.h b/libraries/liblmdb/module.h deleted file mode 100644 index bd5fb3ff14..0000000000 --- a/libraries/liblmdb/module.h +++ /dev/null @@ -1,17 +0,0 @@ -/* module.h - helper for dynamically loading crypto module */ -/* - * Copyright 2020-2021 Howard Chu, Symas Corp. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted only as authorized by the Symas - * Dual-Use License. - * - * A copy of this license is available in the file LICENSE in the - * source distribution. - */ - -void *mlm_load(const char *file, const char *name, MDB_crypto_funcs **mcf_ptr, char **errmsg); -void mlm_unload(void *lm); -void *mlm_setup(MDB_env *env, const char *file, const char *password, char **errmsg); -void mlm_setup0(MDB_env *env, MDB_crypto_funcs *cf, const char *password); -- 2.47.2