From 1a7c409e109b85361909751c0cfce3369a2cd2b5 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Wed, 9 Mar 2011 08:37:26 +1100 Subject: [PATCH] header-mangling-part-X-move-all-headers-defines-into --- lrzip_private.h | 28 +++++-------------------- main.c | 38 ++++++++++++++++++++++++++++++++- md5.c | 3 ++- md5.h | 3 ++- runzip.c | 16 ++++++++++++-- rzip.c | 27 +++++++++++++++++++++++- rzip.h | 56 +------------------------------------------------ stream.c | 30 +++++++++++++++++++++++++- util.c | 13 +++++++++++- util.h | 1 - 10 files changed, 128 insertions(+), 87 deletions(-) diff --git a/lrzip_private.h b/lrzip_private.h index 10ebc98..88e58ec 100644 --- a/lrzip_private.h +++ b/lrzip_private.h @@ -30,14 +30,12 @@ #include #include #include +#ifdef HAVE_STRING_H +# include +#endif -#ifdef __APPLE__ -# define fmemopen fake_fmemopen -# define open_memstream fake_open_memstream -# define memstream_update_buffer fake_open_memstream_update_buffer -# define mremap fake_mremap -#else -# define memstream_update_buffer(A, B, C) (0) +#ifdef HAVE_MALLOC_H +# include #endif #ifndef uchar @@ -94,22 +92,6 @@ typedef long long int i64; typedef uint16_t u16; typedef uint32_t u32; -#ifndef MAP_ANONYMOUS -# define MAP_ANONYMOUS MAP_ANON -#endif - -#if defined(NOTHREAD) || !defined(_SC_NPROCESSORS_ONLN) -# define PROCESSORS (1) -#else -# define PROCESSORS (sysconf(_SC_NPROCESSORS_ONLN)) -#endif - -#ifdef _SC_PAGE_SIZE -# define PAGE_SIZE (sysconf(_SC_PAGE_SIZE)) -#else -# define PAGE_SIZE (4096) -#endif - typedef struct rzip_control rzip_control; typedef struct md5_ctx md5_ctx; diff --git a/main.c b/main.c index f660081..d08ae05 100644 --- a/main.c +++ b/main.c @@ -22,9 +22,32 @@ # include "config.h" #endif +#include +#ifdef HAVE_UNISTD_H +# include +#endif +#ifdef HAVE_CTYPE_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif +#ifdef HAVE_SYS_RESOURCE_H +# include +#endif + + #include "rzip.h" +#include "lrzip.h" #include "util.h" +/* needed for CRC routines */ +#include "lzma/C/7zCrc.h" + +/* Macros for testing parameters */ +#define isparameter( parmstring, value ) (!strcasecmp( parmstring, value )) +#define iscaseparameter( parmvalue, value ) (!strcmp( parmvalue, value )) + /* main() defines, different from liblrzip defines */ #define FLAG_VERBOSE (FLAG_VERBOSITY | FLAG_VERBOSITY_MAX) #define FLAG_NOT_LZMA (FLAG_NO_COMPRESS | FLAG_LZO_COMPRESS | FLAG_BZIP2_COMPRESS | FLAG_ZLIB_COMPRESS | FLAG_ZPAQ_COMPRESS) @@ -73,7 +96,18 @@ print_output(format, ##args); \ } while (0) -rzip_control control; + +#if defined(NOTHREAD) || !defined(_SC_NPROCESSORS_ONLN) +# define PROCESSORS (1) +#else +# define PROCESSORS (sysconf(_SC_NPROCESSORS_ONLN)) +#endif + +#ifdef _SC_PAGE_SIZE +# define PAGE_SIZE (sysconf(_SC_PAGE_SIZE)) +#else +# define PAGE_SIZE (4096) +#endif #ifdef __APPLE__ # include @@ -118,6 +152,8 @@ static inline i64 get_ram(void) } #endif +static rzip_control control; + static void usage(void) { print_output("lrzip version %d.%d%d\n", LRZIP_MAJOR_VERSION, LRZIP_MINOR_VERSION, LRZIP_MINOR_SUBVERSION); diff --git a/md5.c b/md5.c index a13bce9..9df1252 100644 --- a/md5.c +++ b/md5.c @@ -28,8 +28,9 @@ # include "config.h" #endif +#include -#include "rzip.h" +#include "md5.h" #if USE_UNLOCKED_IO # include "unlocked-io.h" diff --git a/md5.h b/md5.h index 136085a..729f2e0 100644 --- a/md5.h +++ b/md5.h @@ -25,9 +25,10 @@ #ifndef _MD5_H #define _MD5_H 1 -#include #include +#include "lrzip_private.h" + #define MD5_DIGEST_SIZE 16 #define MD5_BLOCK_SIZE 64 diff --git a/runzip.c b/runzip.c index 9988f31..5270447 100644 --- a/runzip.c +++ b/runzip.c @@ -21,13 +21,25 @@ # include "config.h" #endif +#include +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif -#include "rzip.h" +#include "md5.h" #include "runzip.h" #include "stream.h" #include "util.h" +#include "lrzip.h" #include "liblrzip.h" - +/* needed for CRC routines */ +#include "lzma/C/7zCrc.h" static inline uchar read_u8(rzip_control *control, void *ss, int stream) { uchar b; diff --git a/rzip.c b/rzip.c index 6aa098f..b2b412b 100644 --- a/rzip.c +++ b/rzip.c @@ -24,10 +24,35 @@ # include "config.h" #endif -#include "rzip.h" +#ifdef HAVE_SYS_MMAN_H +# include +#endif +#include +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif +#include +#include +#ifdef HAVE_ERRNO_H +# include +#endif + +#include "md5.h" #include "stream.h" #include "util.h" #include "liblrzip.h" +/* needed for CRC routines */ +#include "lzma/C/7zCrc.h" + +#ifndef MAP_ANONYMOUS +# define MAP_ANONYMOUS MAP_ANON +#endif #define CHUNK_MULTIPLE (100 * 1024 * 1024) #define CKSUM_CHUNK 1024*1024 diff --git a/rzip.h b/rzip.h index 5c8013e..9c10a65 100644 --- a/rzip.h +++ b/rzip.h @@ -19,62 +19,8 @@ #ifndef RZIP_H #define RZIP_H -#include "lrzip.h" /* includes config.h */ -#include "md5.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -/* LZMA C Wrapper */ -#include "lzma/C/LzmaLib.h" - -#ifdef HAVE_STRING_H -#include -#endif - -#ifdef HAVE_MALLOC_H -#include -#endif - -#include -#include - -#ifdef HAVE_CTYPE_H -#include -#endif -#ifdef HAVE_ERRNO_H -#include -#endif -#include - -/* needed for CRC routines */ -#include "lzma/C/7zCrc.h" +#include "lrzip_private.h" void rzip_fd(rzip_control *control, int fd_in, int fd_out); -/* Macros for testing parameters */ - -#define isparameter( parmstring, value ) (!strcasecmp( parmstring, value )) -#define iscaseparameter( parmvalue, value ) (!strcmp( parmvalue, value )) - #endif diff --git a/stream.c b/stream.c index 7dda7df..8cefbf3 100644 --- a/stream.c +++ b/stream.c @@ -23,11 +23,39 @@ # include "config.h" #endif -#include "rzip.h" +#ifdef HAVE_SYS_TIME_H +# include +#endif +#ifdef HAVE_SYS_RESOURCE_H +# include +#endif +#include +#include +#include +#include +#include +#include +#ifdef HAVE_ERRNO_H +# include +#endif + +/* LZMA C Wrapper */ +#include "lzma/C/LzmaLib.h" + #include "util.h" #include "zpipe.h" #include "liblrzip.h" + +#ifdef __APPLE__ +# define fmemopen fake_fmemopen +# define open_memstream fake_open_memstream +# define memstream_update_buffer fake_open_memstream_update_buffer +# define mremap fake_mremap +#else +# define memstream_update_buffer(A, B, C) (0) +#endif + #define STREAM_BUFSIZE (1024 * 1024 * 10) static struct compress_thread{ diff --git a/util.c b/util.c index 66b0fda..50da3e1 100644 --- a/util.c +++ b/util.c @@ -34,7 +34,18 @@ # include "config.h" #endif -#include "rzip.h" +#include +#ifdef HAVE_UNISTD_H +# include +#endif + +#ifdef _SC_PAGE_SIZE +# define PAGE_SIZE (sysconf(_SC_PAGE_SIZE)) +#else +# define PAGE_SIZE (4096) +#endif + +#include "lrzip_private.h" static const char *infile = NULL; static char delete_infile = 0; diff --git a/util.h b/util.h index 5633738..612517b 100644 --- a/util.h +++ b/util.h @@ -19,7 +19,6 @@ #ifndef LRZIP_UTIL_H #define LRZIP_UTIL_H -#include #include "lrzip_private.h" void register_infile(const char *name, char delete);