summaryrefslogtreecommitdiff
path: root/main/lzo/examples/lzopack.c
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2014-06-29 18:18:50 +0200
committerArne Schwabe <arne@rfc2549.org>2014-06-29 18:18:50 +0200
commit68e19d426ba6d9f048ebfdf337b93a85dc4d5b4c (patch)
treecb33b2698e3f665546a328882c7481b11f633428 /main/lzo/examples/lzopack.c
parentd3aa9f835d7fd5f53d3a0da6778d46a7067bf074 (diff)
Update lzo version
--HG-- extra : rebase_source : 4310223035376c8ac1773fd03a43289aa96ce4f3
Diffstat (limited to 'main/lzo/examples/lzopack.c')
-rw-r--r--main/lzo/examples/lzopack.c75
1 files changed, 29 insertions, 46 deletions
diff --git a/main/lzo/examples/lzopack.c b/main/lzo/examples/lzopack.c
index e4e745df..10e2c1dc 100644
--- a/main/lzo/examples/lzopack.c
+++ b/main/lzo/examples/lzopack.c
@@ -2,22 +2,7 @@
This file is part of the LZO real-time data compression library.
- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The LZO library is free software; you can redistribute it and/or
@@ -76,7 +61,7 @@ static const unsigned char magic[7] =
// file IO
**************************************************************************/
-lzo_uint xread(FILE *fp, lzo_voidp buf, lzo_uint len, lzo_bool allow_eof)
+static lzo_uint xread(FILE *fp, lzo_voidp buf, lzo_uint len, lzo_bool allow_eof)
{
lzo_uint l;
@@ -95,7 +80,7 @@ lzo_uint xread(FILE *fp, lzo_voidp buf, lzo_uint len, lzo_bool allow_eof)
return l;
}
-lzo_uint xwrite(FILE *fp, const lzo_voidp buf, lzo_uint len)
+static lzo_uint xwrite(FILE *fp, const lzo_voidp buf, lzo_uint len)
{
if (fp != NULL && lzo_fwrite(fp, buf, len) != len)
{
@@ -107,14 +92,14 @@ lzo_uint xwrite(FILE *fp, const lzo_voidp buf, lzo_uint len)
}
-int xgetc(FILE *fp)
+static int xgetc(FILE *fp)
{
unsigned char c;
xread(fp, (lzo_voidp) &c, 1, 0);
return c;
}
-void xputc(FILE *fp, int c)
+static void xputc(FILE *fp, int c)
{
unsigned char cc = (unsigned char) (c & 0xff);
xwrite(fp, (const lzo_voidp) &cc, 1);
@@ -122,20 +107,20 @@ void xputc(FILE *fp, int c)
/* read and write portable 32-bit integers */
-lzo_uint32 xread32(FILE *fp)
+static lzo_uint32_t xread32(FILE *fp)
{
unsigned char b[4];
- lzo_uint32 v;
+ lzo_uint32_t v;
xread(fp, b, 4, 0);
- v = (lzo_uint32) b[3] << 0;
- v |= (lzo_uint32) b[2] << 8;
- v |= (lzo_uint32) b[1] << 16;
- v |= (lzo_uint32) b[0] << 24;
+ v = (lzo_uint32_t) b[3] << 0;
+ v |= (lzo_uint32_t) b[2] << 8;
+ v |= (lzo_uint32_t) b[1] << 16;
+ v |= (lzo_uint32_t) b[0] << 24;
return v;
}
-void xwrite32(FILE *fp, lzo_xint v)
+static void xwrite32(FILE *fp, lzo_xint v)
{
unsigned char b[4];
@@ -159,7 +144,7 @@ void xwrite32(FILE *fp, lzo_xint v)
// compression.
**************************************************************************/
-int do_compress(FILE *fi, FILE *fo, int compression_level, lzo_uint block_size)
+static int do_compress(FILE *fi, FILE *fo, int compression_level, lzo_uint block_size)
{
int r = 0;
lzo_bytep in = NULL;
@@ -167,10 +152,10 @@ int do_compress(FILE *fi, FILE *fo, int compression_level, lzo_uint block_size)
lzo_voidp wrkmem = NULL;
lzo_uint in_len;
lzo_uint out_len;
- lzo_uint32 wrk_len = 0;
- lzo_uint32 flags = 1; /* do compute a checksum */
+ lzo_uint wrkmem_size;
+ lzo_uint32_t flags = 1; /* do compute a checksum */
int method = 1; /* compression method: LZO1X */
- lzo_uint32 checksum;
+ lzo_uint32_t checksum;
total_in = total_out = 0;
@@ -190,10 +175,10 @@ int do_compress(FILE *fi, FILE *fo, int compression_level, lzo_uint block_size)
in = (lzo_bytep) xmalloc(block_size);
out = (lzo_bytep) xmalloc(block_size + block_size / 16 + 64 + 3);
if (compression_level == 9)
- wrk_len = LZO1X_999_MEM_COMPRESS;
+ wrkmem_size = LZO1X_999_MEM_COMPRESS;
else
- wrk_len = LZO1X_1_MEM_COMPRESS;
- wrkmem = (lzo_voidp) xmalloc(wrk_len);
+ wrkmem_size = LZO1X_1_MEM_COMPRESS;
+ wrkmem = (lzo_voidp) xmalloc(wrkmem_size);
if (in == NULL || out == NULL || wrkmem == NULL)
{
printf("%s: out of memory\n", progname);
@@ -217,7 +202,7 @@ int do_compress(FILE *fi, FILE *fo, int compression_level, lzo_uint block_size)
/* clear wrkmem (not needed, only for debug/benchmark purposes) */
if (opt_debug)
- lzo_memset(wrkmem, 0xff, wrk_len);
+ lzo_memset(wrkmem, 0xff, wrkmem_size);
/* compress block */
if (compression_level == 9)
@@ -272,17 +257,17 @@ err:
// memory - see overlap.c.
**************************************************************************/
-int do_decompress(FILE *fi, FILE *fo)
+static int do_decompress(FILE *fi, FILE *fo)
{
int r = 0;
lzo_bytep buf = NULL;
lzo_uint buf_len;
unsigned char m [ sizeof(magic) ];
- lzo_uint32 flags;
+ lzo_uint32_t flags;
int method;
int compression_level;
lzo_uint block_size;
- lzo_uint32 checksum;
+ lzo_uint32_t checksum;
total_in = total_out = 0;
@@ -307,7 +292,7 @@ int do_decompress(FILE *fi, FILE *fo)
goto err;
}
block_size = xread32(fi);
- if (block_size < 1024 || block_size > 8*1024*1024L)
+ if (block_size < 1024 || block_size > 8L * 1024L * 1024L)
{
printf("%s: header error - invalid block size %ld\n",
progname, (long) block_size);
@@ -396,7 +381,7 @@ int do_decompress(FILE *fi, FILE *fo)
/* read and verify checksum */
if (flags & 1)
{
- lzo_uint32 c = xread32(fi);
+ lzo_uint32_t c = xread32(fi);
if (c != checksum)
{
printf("%s: checksum error - data corrupted\n", progname);
@@ -524,7 +509,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
printf("\nLZO real-time data compression library (v%s, %s).\n",
lzo_version_string(), lzo_version_date());
- printf("Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
+ printf("Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
#if 0
printf(
@@ -552,9 +537,9 @@ int __lzo_cdecl_main main(int argc, char *argv[])
*/
opt_block_size = 256 * 1024L;
-#if defined(ACC_MM_AHSHIFT)
+#if defined(LZO_MM_AHSHIFT)
/* reduce memory requirements for ancient 16-bit DOS 640kB real-mode */
- if (ACC_MM_AHSHIFT != 3)
+ if (LZO_MM_AHSHIFT != 3)
opt_block_size = 16 * 1024L;
#endif
@@ -639,7 +624,5 @@ int __lzo_cdecl_main main(int argc, char *argv[])
return r;
}
-/*
-vi:ts=4:et
-*/
+/* vim:set ts=4 sw=4 et: */