header-mangling-part-2-move-all-function-prototypes

This commit is contained in:
Con Kolivas 2011-03-09 08:34:44 +11:00
parent e5dfd2d9d8
commit 1511c27aad
14 changed files with 422 additions and 245 deletions

View file

@ -17,7 +17,13 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "rzip.h" #include "rzip.h"
#include "runzip.h"
#include "util.h"
#include "liblrzip.h" /* flag defines */ #include "liblrzip.h" /* flag defines */
void write_magic(rzip_control *control, int fd_in, int fd_out) void write_magic(rzip_control *control, int fd_in, int fd_out)

203
lrzip.h
View file

@ -19,208 +19,7 @@
#ifndef LRZIP_H #ifndef LRZIP_H
#define LRZIP_H #define LRZIP_H
#define LRZIP_MAJOR_VERSION VMAJ #include "lrzip_private.h"
#define LRZIP_MINOR_VERSION VMIN
#define LRZIP_MINOR_SUBVERSION VMIC
#define NUM_STREAMS 2
#define STREAM_BUFSIZE (1024 * 1024 * 10)
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include <stdint.h>
#include <stdio.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
#ifndef uchar
#define uchar unsigned char
#endif
#ifndef int32
#if (SIZEOF_INT == 4)
#define int32 int
#elif (SIZEOF_LONG == 4)
#define int32 long
#elif (SIZEOF_SHORT == 4)
#define int32 short
#endif
#endif
#ifndef int16
#if (SIZEOF_INT == 2)
#define int16 int
#elif (SIZEOF_SHORT == 2)
#define int16 short
#endif
#endif
#ifndef uint32
#define uint32 unsigned int32
#endif
#ifndef uint16
#define uint16 unsigned int16
#endif
#ifndef MIN
#define MIN(a, b) ((a) < (b)? (a): (b))
#endif
#ifndef MAX
#define MAX(a, b) ((a) > (b)? (a): (b))
#endif
#if !HAVE_STRERROR
extern char *sys_errlist[];
#define strerror(i) sys_errlist[i]
#endif
#ifndef HAVE_ERRNO_H
extern int errno;
#endif
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
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;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#define mremap fake_mremap
#endif
#define FLAG_SHOW_PROGRESS (1 << 0)
#define FLAG_KEEP_FILES (1 << 1)
#define FLAG_TEST_ONLY (1 << 2)
#define FLAG_FORCE_REPLACE (1 << 3)
#define FLAG_DECOMPRESS (1 << 4)
#define FLAG_NO_COMPRESS (1 << 5)
#define FLAG_LZO_COMPRESS (1 << 6)
#define FLAG_BZIP2_COMPRESS (1 << 7)
#define FLAG_ZLIB_COMPRESS (1 << 8)
#define FLAG_ZPAQ_COMPRESS (1 << 9)
#define FLAG_VERBOSITY (1 << 10)
#define FLAG_VERBOSITY_MAX (1 << 11)
#define FLAG_STDIN (1 << 12)
#define FLAG_STDOUT (1 << 13)
#define FLAG_INFO (1 << 14)
#define FLAG_UNLIMITED (1 << 15)
#define FLAG_HASH (1 << 16)
#define FLAG_MD5 (1 << 17)
#define FLAG_CHECK (1 << 18)
#define FLAG_KEEP_BROKEN (1 << 19)
#define FLAG_THRESHOLD (1 << 20)
#define NO_MD5 (!(HASH_CHECK) && !(HAS_MD5))
#define BITS32 (sizeof(long) == 4)
#define CTYPE_NONE 3
#define CTYPE_BZIP2 4
#define CTYPE_LZO 5
#define CTYPE_LZMA 6
#define CTYPE_GZIP 7
#define CTYPE_ZPAQ 8
/* Structure to save state of computation between the single steps. */
struct md5_ctx
{
uint32_t A;
uint32_t B;
uint32_t C;
uint32_t D;
uint32_t total[2];
uint32_t buflen;
uint32_t buffer[32];
};
struct rzip_control {
char *infile;
char *outname;
char *outfile;
char *outdir;
char *tmpdir; // when stdin, stdout, or test used
FILE *msgout; //stream for output messages
const char *suffix;
int compression_level;
i64 overhead; // compressor overhead
i64 maxram; // the largest chunk of ram to allocate
unsigned char lzma_properties[5]; // lzma properties, encoded
i64 window;
unsigned long flags;
i64 ramsize;
i64 max_chunk;
i64 max_mmap;
int threads;
int nice_val; // added for consistency
int major_version;
int minor_version;
i64 st_size;
long page_size;
int fd_out;
md5_ctx ctx;
void *data; // random data pointer associated for use in callbacks
i64 md5_read; // How far into the file the md5 has done so far
};
struct stream {
i64 last_head;
uchar *buf;
i64 buflen;
i64 bufp;
int eos;
long uthread_no;
long unext_thread;
long base_thread;
int total_threads;
};
struct stream_info {
struct stream *s;
int num_streams;
int fd;
i64 bufsize;
i64 cur_pos;
i64 initial_pos;
i64 total_read;
i64 ram_alloced;
long thread_no;
long next_thread;
int chunks;
char chunk_bytes;
};
void write_magic(rzip_control *control, int fd_in, int fd_out); void write_magic(rzip_control *control, int fd_in, int fd_out);
void read_magic(rzip_control *control, int fd_in, i64 *expected_size); void read_magic(rzip_control *control, int fd_in, i64 *expected_size);

229
lrzip_private.h Normal file
View file

@ -0,0 +1,229 @@
/*
Copyright (C) 2006-2011 Con Kolivas
Copyright (C) 2011 Peter Hyman
Copyright (C) 1998-2003 Andrew Tridgell
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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 <http://www.gnu.org/licenses/>.
*/
#ifndef LRZIP_PRIV_H
#define LRZIP_PRIV_H
#define LRZIP_MAJOR_VERSION VMAJ
#define LRZIP_MINOR_VERSION VMIN
#define LRZIP_MINOR_SUBVERSION VMIC
#define NUM_STREAMS 2
#define STREAM_BUFSIZE (1024 * 1024 * 10)
#include <stdlib.h>
#include <stdint.h>
#include <stdio.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
#ifndef uchar
#define uchar unsigned char
#endif
#ifndef int32
#if (SIZEOF_INT == 4)
#define int32 int
#elif (SIZEOF_LONG == 4)
#define int32 long
#elif (SIZEOF_SHORT == 4)
#define int32 short
#endif
#endif
#ifndef int16
#if (SIZEOF_INT == 2)
#define int16 int
#elif (SIZEOF_SHORT == 2)
#define int16 short
#endif
#endif
#ifndef uint32
#define uint32 unsigned int32
#endif
#ifndef uint16
#define uint16 unsigned int16
#endif
#ifndef MIN
#define MIN(a, b) ((a) < (b)? (a): (b))
#endif
#ifndef MAX
#define MAX(a, b) ((a) > (b)? (a): (b))
#endif
#if !HAVE_STRERROR
extern char *sys_errlist[];
#define strerror(i) sys_errlist[i]
#endif
#ifndef HAVE_ERRNO_H
extern int errno;
#endif
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
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;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# define mremap fake_mremap
#endif
#define FLAG_SHOW_PROGRESS (1 << 0)
#define FLAG_KEEP_FILES (1 << 1)
#define FLAG_TEST_ONLY (1 << 2)
#define FLAG_FORCE_REPLACE (1 << 3)
#define FLAG_DECOMPRESS (1 << 4)
#define FLAG_NO_COMPRESS (1 << 5)
#define FLAG_LZO_COMPRESS (1 << 6)
#define FLAG_BZIP2_COMPRESS (1 << 7)
#define FLAG_ZLIB_COMPRESS (1 << 8)
#define FLAG_ZPAQ_COMPRESS (1 << 9)
#define FLAG_VERBOSITY (1 << 10)
#define FLAG_VERBOSITY_MAX (1 << 11)
#define FLAG_STDIN (1 << 12)
#define FLAG_STDOUT (1 << 13)
#define FLAG_INFO (1 << 14)
#define FLAG_UNLIMITED (1 << 15)
#define FLAG_HASH (1 << 16)
#define FLAG_MD5 (1 << 17)
#define FLAG_CHECK (1 << 18)
#define FLAG_KEEP_BROKEN (1 << 19)
#define FLAG_THRESHOLD (1 << 20)
#define NO_MD5 (!(HASH_CHECK) && !(HAS_MD5))
#define BITS32 (sizeof(long) == 4)
#define CTYPE_NONE 3
#define CTYPE_BZIP2 4
#define CTYPE_LZO 5
#define CTYPE_LZMA 6
#define CTYPE_GZIP 7
#define CTYPE_ZPAQ 8
/* Needs to be less than 31 bits and page aligned on 32 bits */
#define two_gig ((1ull << 31) - 4096)
#define print_err(format, args...) do {\
fprintf(stderr, format, ##args); \
} while (0)
/* Structure to save state of computation between the single steps. */
struct md5_ctx
{
uint32_t A;
uint32_t B;
uint32_t C;
uint32_t D;
uint32_t total[2];
uint32_t buflen;
uint32_t buffer[32];
};
struct rzip_control {
char *infile;
char *outname;
char *outfile;
char *outdir;
char *tmpdir; // when stdin, stdout, or test used
FILE *msgout; //stream for output messages
const char *suffix;
int compression_level;
i64 overhead; // compressor overhead
i64 maxram; // the largest chunk of ram to allocate
unsigned char lzma_properties[5]; // lzma properties, encoded
i64 window;
unsigned long flags;
i64 ramsize;
i64 max_chunk;
i64 max_mmap;
int threads;
int nice_val; // added for consistency
int major_version;
int minor_version;
i64 st_size;
long page_size;
int fd_out;
md5_ctx ctx;
void *data; // random data pointer associated for use in callbacks
i64 md5_read; // How far into the file the md5 has done so far
};
struct stream {
i64 last_head;
uchar *buf;
i64 buflen;
i64 bufp;
int eos;
long uthread_no;
long unext_thread;
long base_thread;
int total_threads;
};
struct stream_info {
struct stream *s;
int num_streams;
int fd;
i64 bufsize;
i64 cur_pos;
i64 initial_pos;
i64 total_read;
i64 ram_alloced;
long thread_no;
long next_thread;
int chunks;
char chunk_bytes;
};
#endif

12
main.c
View file

@ -18,7 +18,13 @@
*/ */
/* lrzip compression - main program */ /* lrzip compression - main program */
#define MAIN_C #define MAIN_C
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "rzip.h" #include "rzip.h"
#include "util.h"
/* main() defines, different from liblrzip defines */ /* main() defines, different from liblrzip defines */
#define FLAG_VERBOSE (FLAG_VERBOSITY | FLAG_VERBOSITY_MAX) #define FLAG_VERBOSE (FLAG_VERBOSITY | FLAG_VERBOSITY_MAX)
@ -159,6 +165,12 @@ static void usage(void)
} }
static void sighandler(int sig __UNUSED__)
{
unlink_files();
exit(0);
}
static void show_summary(void) static void show_summary(void)
{ {
/* OK, if verbosity set, print summary of options selected */ /* OK, if verbosity set, print summary of options selected */

5
md5.c
View file

@ -24,6 +24,11 @@
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */ /* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "rzip.h" #include "rzip.h"
#if USE_UNLOCKED_IO #if USE_UNLOCKED_IO

View file

@ -17,7 +17,15 @@
*/ */
/* rzip decompression algorithm */ /* rzip decompression algorithm */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "rzip.h" #include "rzip.h"
#include "runzip.h"
#include "stream.h"
#include "util.h"
static inline uchar read_u8(rzip_control *control, void *ss, int stream) static inline uchar read_u8(rzip_control *control, void *ss, int stream)
{ {

27
runzip.h Normal file
View file

@ -0,0 +1,27 @@
/*
Copyright (C) 2006-2011 Con Kolivas
Copyright (C) 2011 Peter Hyman
Copyright (C) 1998-2003 Andrew Tridgell
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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 <http://www.gnu.org/licenses/>.
*/
#ifndef RUNZIP_H
#define RUNZIP_H
#include "lrzip_private.h"
i64 runzip_fd(rzip_control *control, int fd_in, int fd_out, int fd_hist, i64 expected_size);
#endif

14
rzip.c
View file

@ -19,7 +19,14 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* rzip compression algorithm */ /* rzip compression algorithm */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "rzip.h" #include "rzip.h"
#include "stream.h"
#include "util.h"
#define CHUNK_MULTIPLE (100 * 1024 * 1024) #define CHUNK_MULTIPLE (100 * 1024 * 1024)
#define CKSUM_CHUNK 1024*1024 #define CKSUM_CHUNK 1024*1024
@ -206,7 +213,7 @@ static void put_match(rzip_control *control, struct rzip_state *st, i64 p, i64 o
} }
/* write some data to a stream mmap encoded. Return -1 on failure */ /* write some data to a stream mmap encoded. Return -1 on failure */
int write_sbstream(rzip_control *control, void *ss, int stream, i64 p, i64 len) static int write_sbstream(rzip_control *control, void *ss, int stream, i64 p, i64 len)
{ {
struct stream_info *sinfo = ss; struct stream_info *sinfo = ss;
@ -719,9 +726,6 @@ static void rzip_chunk(rzip_control *control, struct rzip_state *st, int fd_in,
fatal("Failed to flush/close streams in rzip_chunk\n"); fatal("Failed to flush/close streams in rzip_chunk\n");
} }
/* Needs to be less than 31 bits and page aligned on 32 bits */
const i64 two_gig = (1ull << 31) - 4096;
/* compress a whole file chunks at a time */ /* compress a whole file chunks at a time */
void rzip_fd(rzip_control *control, int fd_in, int fd_out) void rzip_fd(rzip_control *control, int fd_in, int fd_out)
{ {
@ -783,7 +787,7 @@ void rzip_fd(rzip_control *control, int fd_in, int fd_out)
/* On 32 bits we can have a big window with sliding mmap, but can /* On 32 bits we can have a big window with sliding mmap, but can
* not enable much per mmap/malloc */ * not enable much per mmap/malloc */
if (BITS32) if (BITS32)
control->max_mmap = MIN(control->max_mmap, two_gig); control->max_mmap = MIN((unsigned long long)control->max_mmap, two_gig);
round_to_page(&control->max_mmap); round_to_page(&control->max_mmap);
/* Set maximum chunk size to 2/3 of ram if not unlimited or specified /* Set maximum chunk size to 2/3 of ram if not unlimited or specified

28
rzip.h
View file

@ -71,35 +71,7 @@
/* needed for CRC routines */ /* needed for CRC routines */
#include "lzma/C/7zCrc.h" #include "lzma/C/7zCrc.h"
void fatal(const char *format, ...);
void failure(const char *format, ...);
void sighandler();
i64 runzip_fd(rzip_control *control, int fd_in, int fd_out, int fd_hist, i64 expected_size);
void rzip_fd(rzip_control *control, int fd_in, int fd_out); void rzip_fd(rzip_control *control, int fd_in, int fd_out);
void *open_stream_out(rzip_control *control, int f, int n, i64 limit, char cbytes);
void *open_stream_in(rzip_control *control, int f, int n);
int write_stream(rzip_control *control, void *ss, int stream, uchar *p, i64 len);
i64 read_stream(rzip_control *control, void *ss, int stream, uchar *p, i64 len);
int close_stream_out(rzip_control *control, void *ss);
int close_stream_in(void *ss);
void flush_buffer(rzip_control *control, struct stream_info *sinfo, int stream);
ssize_t write_1g(int fd, void *buf, i64 len);
ssize_t read_1g(int fd, void *buf, i64 len);
void zpipe_compress(FILE *in, FILE *out, FILE *msgout, long long int buf_len, int progress, long thread);
void zpipe_decompress(FILE *in, FILE *out, FILE *msgout, long long int buf_len, int progress, long thread);
const i64 two_gig;
void prepare_streamout_threads(rzip_control *control);
void close_streamout_threads(rzip_control *control);
void round_to_page(i64 *size);
void register_infile(const char *name, char delete);
void register_outfile(const char *name, char delete);
void register_outputfile(FILE *f);
#define print_err(format, args...) do {\
fprintf(stderr, format, ##args); \
} while (0)
/* Macros for testing parameters */ /* Macros for testing parameters */

View file

@ -19,7 +19,13 @@
/* multiplex N streams into a file - the streams are passed /* multiplex N streams into a file - the streams are passed
through different compressors */ through different compressors */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "rzip.h" #include "rzip.h"
#include "util.h"
#include "zpipe.h"
#define STREAM_BUFSIZE (1024 * 1024 * 10) #define STREAM_BUFSIZE (1024 * 1024 * 10)
@ -763,12 +769,12 @@ void close_streamout_threads(rzip_control *control)
/* open a set of output streams, compressing with the given /* open a set of output streams, compressing with the given
compression level and algorithm */ compression level and algorithm */
void *open_stream_out(rzip_control *control, int f, int n, i64 chunk_limit, char cbytes) void *open_stream_out(rzip_control *control, int f, unsigned int n, i64 chunk_limit, char cbytes)
{ {
struct stream_info *sinfo; struct stream_info *sinfo;
i64 testsize, limit; i64 testsize, limit;
uchar *testmalloc; uchar *testmalloc;
int i, testbufs; unsigned int i, testbufs;
sinfo = calloc(sizeof(struct stream_info), 1); sinfo = calloc(sizeof(struct stream_info), 1);
if (unlikely(!sinfo)) if (unlikely(!sinfo))
@ -798,7 +804,7 @@ void *open_stream_out(rzip_control *control, int f, int n, i64 chunk_limit, char
/* Serious limits imposed on 32 bit capabilities */ /* Serious limits imposed on 32 bit capabilities */
if (BITS32) if (BITS32)
limit = MIN(limit, (two_gig / testbufs) - limit = MIN((unsigned long long)limit, (two_gig / testbufs) -
(control->overhead * control->threads)); (control->overhead * control->threads));
testsize = (limit * testbufs) + (control->overhead * control->threads); testsize = (limit * testbufs) + (control->overhead * control->threads);

41
stream.h Normal file
View file

@ -0,0 +1,41 @@
/*
Copyright (C) 2006-2011 Con Kolivas
Copyright (C) 2011 Peter Hyman
Copyright (C) 1998-2003 Andrew Tridgell
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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 <http://www.gnu.org/licenses/>.
*/
#ifndef LRZIP_STREAM_H
#define LRZIP_STREAM_H
#include "lrzip_private.h"
#include <pthread.h>
void create_pthread(pthread_t *thread, pthread_attr_t *attr,
void * (*start_routine)(void *), void *arg);
void join_pthread(pthread_t th, void **thread_return);
ssize_t write_1g(int fd, void *buf, i64 len);
ssize_t read_1g(int fd, void *buf, i64 len);
void prepare_streamout_threads(rzip_control *control);
void close_streamout_threads(rzip_control *control);
void *open_stream_out(rzip_control *control, int f, unsigned int n, i64 chunk_limit, char cbytes);
void *open_stream_in(rzip_control *control, int f, int n);
void flush_buffer(rzip_control *control, struct stream_info *sinfo, int stream);
int write_stream(rzip_control *control, void *ss, int stream, uchar *p, i64 len);
i64 read_stream(rzip_control *control, void *ss, int stream, uchar *p, i64 len);
int close_stream_out(rzip_control *control, void *ss);
int close_stream_in(void *ss);
#endif

12
util.c
View file

@ -30,6 +30,10 @@
* Peter Hyman, December 2008 * Peter Hyman, December 2008
*/ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "rzip.h" #include "rzip.h"
static const char *infile = NULL; static const char *infile = NULL;
@ -55,7 +59,7 @@ void register_outputfile(FILE *f)
outputfile = f; outputfile = f;
} }
static void unlink_files(void) void unlink_files(void)
{ {
/* Delete temporary files generated for testing or faking stdio */ /* Delete temporary files generated for testing or faking stdio */
if (outfile && delete_outfile) if (outfile && delete_outfile)
@ -101,12 +105,6 @@ void failure(const char *format, ...)
fatal_exit(); fatal_exit();
} }
void sighandler()
{
unlink_files();
exit(0);
}
void round_to_page(i64 *size) void round_to_page(i64 *size)
{ {
*size -= *size % PAGE_SIZE; *size -= *size % PAGE_SIZE;

33
util.h Normal file
View file

@ -0,0 +1,33 @@
/*
Copyright (C) 2006-2011 Con Kolivas
Copyright (C) 2011 Peter Hyman
Copyright (C) 1998 Andrew Tridgell
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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 <http://www.gnu.org/licenses/>.
*/
#ifndef LRZIP_UTIL_H
#define LRZIP_UTIL_H
#include <stdio.h>
#include "lrzip_private.h"
void register_infile(const char *name, char delete);
void register_outfile(const char *name, char delete);
void unlink_files(void);
void register_outputfile(FILE *f);
void fatal(const char *format, ...);
void failure(const char *format, ...);
void round_to_page(i64 *size);
#endif

37
zpipe.h Normal file
View file

@ -0,0 +1,37 @@
/* zpipe streaming file compressor v1.0
(C) 2009, Ocarina Networks, Inc.
Written by Matt Mahoney, matmahoney@yahoo.com, Sept. 29, 2009.
LICENSE
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 3 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details at
Visit <http://www.gnu.org/copyleft/gpl.html>.
*/
#ifndef ZPIPE_H
#define ZPIPE_H
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
void zpipe_compress(FILE *in, FILE *out, FILE *msgout, long long int buf_len,
int progress, long thread);
void zpipe_decompress(FILE *in, FILE *out, FILE *msgout, long long int buf_len, int progress, long thread);
#ifdef __cplusplus
}
#endif
#endif