header-mangling-part-X-move-all-headers-defines-into

This commit is contained in:
Con Kolivas 2011-03-09 08:37:26 +11:00
parent e9eee5656b
commit 1a7c409e10
10 changed files with 128 additions and 87 deletions

View file

@ -30,14 +30,12 @@
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#ifdef HAVE_STRING_H
# include <string.h>
#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 <malloc.h>
#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;

38
main.c
View file

@ -22,9 +22,32 @@
# include "config.h"
#endif
#include <signal.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_CTYPE_H
# include <ctype.h>
#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#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 <sys/sysctl.h>
@ -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);

3
md5.c
View file

@ -28,8 +28,9 @@
# include "config.h"
#endif
#include <stddef.h>
#include "rzip.h"
#include "md5.h"
#if USE_UNLOCKED_IO
# include "unlocked-io.h"

3
md5.h
View file

@ -25,9 +25,10 @@
#ifndef _MD5_H
#define _MD5_H 1
#include <stdio.h>
#include <stdint.h>
#include "lrzip_private.h"
#define MD5_DIGEST_SIZE 16
#define MD5_BLOCK_SIZE 64

View file

@ -21,13 +21,25 @@
# include "config.h"
#endif
#include <sys/types.h>
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#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;

27
rzip.c
View file

@ -24,10 +24,35 @@
# include "config.h"
#endif
#include "rzip.h"
#ifdef HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif
#include <sys/statvfs.h>
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <lzo/lzoconf.h>
#include <lzo/lzo1x.h>
#ifdef HAVE_ERRNO_H
# include <errno.h>
#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

56
rzip.h
View file

@ -19,62 +19,8 @@
#ifndef RZIP_H
#define RZIP_H
#include "lrzip.h" /* includes config.h */
#include "md5.h"
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stddef.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <bzlib.h>
#include <zlib.h>
#include <pthread.h>
#include <sys/statvfs.h>
#include <sys/resource.h>
#include <netinet/in.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <lzo/lzoconf.h>
#include <lzo/lzo1x.h>
/* LZMA C Wrapper */
#include "lzma/C/LzmaLib.h"
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#include <fcntl.h>
#include <sys/stat.h>
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#include <sys/mman.h>
/* 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

View file

@ -23,11 +23,39 @@
# include "config.h"
#endif
#include "rzip.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
#include <sys/statvfs.h>
#include <pthread.h>
#include <bzlib.h>
#include <zlib.h>
#include <lzo/lzoconf.h>
#include <lzo/lzo1x.h>
#ifdef HAVE_ERRNO_H
# include <errno.h>
#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{

13
util.c
View file

@ -34,7 +34,18 @@
# include "config.h"
#endif
#include "rzip.h"
#include <stdarg.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#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;

1
util.h
View file

@ -19,7 +19,6 @@
#ifndef LRZIP_UTIL_H
#define LRZIP_UTIL_H
#include <stdio.h>
#include "lrzip_private.h"
void register_infile(const char *name, char delete);