Index: Docs/file_format.txt ================================================================== --- Docs/file_format.txt +++ Docs/file_format.txt @@ -50,23 +50,6 @@ 10 No-op 11 IDXDATA (Not used) ? 12 SFX length (Not used) ? 13 SHA256 of original file (binary) ------ -ALGO values: - 0 Uncompressed - 1 RLE Compression - 2 Delta Compression - 3 Text Compression - 4 Zlib Compression - 5 Modified Zlib Compression - 6 Seminibble Encoding - 7 Range Encoding - 8 Second Modified Zlib Compression - 9 Bzip2 Compression - 10 Factor Compression - 11 Bitsums Compression - 12 Text RLE Compression - 13 LZO-1x Compression - 14 LZO-1y Compression - 15 LZO-2a Compression - 255 Reserved / Invalid +ALGO values: Specified in "registration/compression" Index: Makefile.in ================================================================== --- Makefile.in +++ Makefile.in @@ -52,15 +52,17 @@ echo ' *;' >> libdact.vers echo '};' >> libdact.vers ## Build structures of registered components ### Compression algorithms -algorithms.h algorithms.c: algorithms.h.in algorithms.c.in registration/compression - false +algorithm-defs.h: registration/compression + sed 's@#.*@@' registration/compression | grep -v '^ *$$' | awk '{ print "#define DACT_COMP_ALGO_" toupper($$2) "_ID " $$1 }' > algorithm-defs.h + +builtin-algorithms.c: builtin-algorithms.c.in registration/compression ### Encryption algorithms -ciphers.h ciphers.c: ciphers.h.in ciphers.c.in registration/compression +ciphers.h builtin-ciphers.c: ciphers.h.in builtin-ciphers.c.in registration/encryption false # Generic build rules %.o: %.c $(CC) $(CPPFLAGS) $(CFLAGS) -o "$@" -c "$^" @@ -67,10 +69,11 @@ %_shr.o: %.c $(CC) $(CPPFLAGS) $(CFLAGS) $(SHOBJFLAGS) -o "$@" -c "$^" # Dependencies +algorithms.h: algorithm-defs.h libdact_combined.o: libdact_combined.c libdact_combined_shr.o: libdact_combined.c libdact.o: libdact.c libdact_shr.o: libdact.c @@ -83,9 +86,11 @@ distclean: clean rm -f config.h Makefile libdact.syms rm -f config.status config.log mrproper: distclean + rm -f libdact.vers + rm -f algorithm-defs.h builtin-algorithms.c ./build/autogen.sh distclean # Make directive targets .PHONY: all clean distclean mrproper ADDED algorithm-defs.h Index: algorithm-defs.h ================================================================== --- /dev/null +++ algorithm-defs.h @@ -0,0 +1,16 @@ +#define DACT_COMP_ALGO_PLAIN_ID 0 +#define DACT_COMP_ALGO_RLE_ID 1 +#define DACT_COMP_ALGO_DELTA_ID 2 +#define DACT_COMP_ALGO_TEXT_ID 3 +#define DACT_COMP_ALGO_ZLIB_ID 4 +#define DACT_COMP_ALGO_MZLIB_ID 5 +#define DACT_COMP_ALGO_SNIBBLE_ID 6 +#define DACT_COMP_ALGO_RANGE_ID 7 +#define DACT_COMP_ALGO_MZLIB2_ID 8 +#define DACT_COMP_ALGO_BZIP2_ID 9 +#define DACT_COMP_ALGO_FACTOR_ID 10 +#define DACT_COMP_ALGO_BITSUMS_ID 11 +#define DACT_COMP_ALGO_TEXTRLE_ID 12 +#define DACT_COMP_ALGO_LZOOX_ID 13 +#define DACT_COMP_ALGO_LZOOY_ID 14 +#define DACT_COMP_ALGO_LZOTA_ID 15 Index: algorithms.h ================================================================== --- algorithms.h +++ algorithms.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2001, 2002, and 2003 Roy Keene + * Copyright (C) 2013 Roy Keene * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. @@ -12,155 +12,25 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * email: dact@rkeene.org - */ - -#ifndef _ALGORITHMS_H -#define _ALOGIRTHMS_H -/* - Algorithms! -*/ - -#include "dact.h" -#include "comp_plain.h" -#include "comp_rle.h" -#include "comp_delta.h" -#ifdef HAVE_LIBZ -#include "comp_zlib.h" -#include "comp_mzlib.h" -#include "comp_mzlib2.h" -#endif -#ifdef HAVE_LIBBZ2 -#include "comp_bzlib.h" -#endif -#ifdef DEBUG -#include "comp_factor.h" -#include "comp_bitsums.h" -#include "comp_textrle.h" -#endif -#include "comp_snibble.h" -#include "comp_text.h" -#include "comp_fail.h" -#include "comp_lzoox.h" -#include "comp_lzooy.h" -#include "comp_lzota.h" - -#ifdef __DACT_C -int (*(algorithms[256]))()={ comp_plain_algo, - comp_rle_algo, - comp_delta_algo, - comp_text_algo, -#ifdef HAVE_LIBZ - comp_zlib_algo, - comp_mzlib_algo, -#else - DACT_FAILED_ALGO, - DACT_FAILED_ALGO, -#endif - comp_snibble_algo, - DACT_FAILED_ALGO, -#ifdef HAVE_LIBZ - comp_mzlib2_algo, -#else - DACT_FAILED_ALGO, -#endif -#ifdef HAVE_LIBBZ2 - comp_bzlib_algo, -#else - DACT_FAILED_ALGO, -#endif -#ifdef DEBUG - comp_factor_algo, - comp_bitsums_algo, - comp_textrle_algo, -#else - DACT_FAILED_ALGO, - DACT_FAILED_ALGO, - DACT_FAILED_ALGO, -#endif - comp_lzoox_algo, - comp_lzooy_algo, - comp_lzota_algo, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, - NULL}; - -char *algorithm_names[256]={ "Uncompressed", - "RLE Compression", - "Delta Compression", - "Text Compression", -#ifdef HAVE_LIBZ - "Zlib Compression", - "Modified Zlib Compression", -#else - "Unsupported Algorithm (zlib)", - "Unsupported Algorithm (mzlib)", -#endif - "Seminibble Encoding", - "Range Encoding", -#ifdef HAVE_LIBZ - "Second Modified Zlib Compression", -#else - "Unsupported Algorithm (mzlib2)", -#endif -#ifdef HAVE_LIBBZ2 - "Bzip2 Compression", -#else - "Unsupported Algorithm (bzlib)", -#endif -#ifdef DEBUG - "Factor Compression", - "Bitsums Compression", - "Text RLE Compression", -#else - "Unsupported Algorithm (factor)", - "Unsupported Algorithm (bitsums)", - "Unsupported Algorithm (textrle)", -#endif -#ifdef HAVE_LIBLZO - "LZO-1x Compression", - "LZO-1y Compression", - "LZO-2a Compression", -#else - "Unsupported Algorithm (comp_lzoox)", - "Unsupported Algorithm (comp_lzooy)", - "Unsupported Algorithm (comp_lzota)", -#endif - NULL - }; -#else -extern int (*(algorithms[256]))(); -extern char *algorithm_names[256]; -#endif + * email: dact@rkeene.org + */ +#ifndef DACT_ALGORITHMS_H +#define DACT_ALGORITHMS_H 1 + +#include "algorithm-defs.h" + +typedef enum { + DACT_MODE_COMPR = 1, + DACT_MODE_DECMP = 2 +} dact_mode_t; + +struct dact_compression_algo { + char *name; + int id; + + int (*function)(dact_mode_t mode, unsigned char *prev, unsigned char *block, unsigned char *out, int size, int bufsize); +}; + #endif ADDED builtin-algorithms.c.in Index: builtin-algorithms.c.in ================================================================== --- /dev/null +++ builtin-algorithms.c.in ADDED libdact_combined.c Index: libdact_combined.c ================================================================== --- /dev/null +++ libdact_combined.c @@ -0,0 +1,35 @@ +int dact_register_hook() { +} + +int dact_load_module() { +} + +int dact_load_all_modules() { +} + +int dact_set_option() { +} + +int dact_parse_config() { +} + +int dact_parse_cmdline() { +} + +int dact_CtxDecompress() { +} + +int dact_CtxCompress() { +} + +int dact_BuffToBuffDecompress() { +} + +int dact_BuffToBuffCompress() { +} + +int dact_Decompress() { +} + +int dact_Compress() { +} Index: registration/compression ================================================================== --- registration/compression +++ registration/compression @@ -1,1 +1,16 @@ -0 plain Plain compression +0 plain Uncompressed +1 rle RLE Compression +2 delta Delta Compression +3 text Text Compression +4 zlib Zlib Compression +5 mzlib Modified Zlib Compression +6 snibble Seminibble Encoding +7 range Range Encoding +8 mzlib2 Second Modified Zlib Compression +9 bzip2 Bzip2 Compression +10 factor Factor Compression +11 bitsums Bitsums Compression +12 textrle Text RLE Compression +13 lzoox LZO-1x Compression +14 lzooy LZO-1y Compression +15 lzota LZO-2a Compression