Copyright (c) 2001 Matthias Kramm <kramm@quiss.org>
- This file is distributed under the GPL, see file COPYING for details */#include <stdio.h>
+ This file is distributed under the GPL, see file COPYING for details */
+#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <memory.h>
#include <fcntl.h>
-#include <zlib.h>
-#include "./bitio.h"
+#include "../config.h"
+
+#ifdef HAVE_ZLIB
+#include <zlib.h>
#define ZLIB_BUFFER_SIZE 16384
+#endif
+#include "./bitio.h"
struct memread_t
{
struct zlibinflate_t
{
+#ifdef HAVE_ZLIB
z_stream zs;
struct reader_t*input;
unsigned char readbuffer[ZLIB_BUFFER_SIZE];
+#endif
};
struct zlibdeflate_t
{
+#ifdef HAVE_ZLIB
z_stream zs;
struct writer_t*output;
unsigned char writebuffer[ZLIB_BUFFER_SIZE];
+#endif
};
void reader_resetbits(struct reader_t*r)
static int reader_zlibinflate(struct reader_t*reader, void* data, int len);
static int reader_fileread(struct reader_t*reader, void* data, int len);
static int reader_memread(struct reader_t*reader, void* data, int len);
+#ifdef HAVE_ZLIB
static void zlib_error(int ret, char* msg, z_stream*zs);
+#endif
void reader_init_filereader(struct reader_t*r, int handle)
{
void reader_init_zlibinflate(struct reader_t*r, struct reader_t*input)
{
+#ifdef HAVE_ZLIB
struct zlibinflate_t*z;
int ret;
memset(r, 0, sizeof(struct reader_t));
ret = inflateInit(&z->zs);
if (ret != Z_OK) zlib_error(ret, "bitio:inflate_init", &z->zs);
reader_resetbits(r);
+#else
+ fprintf(stderr, "Error: swftools was compiled without zlib support");
+#endif
}
+#ifdef HAVE_ZLIB
static void zlib_error(int ret, char* msg, z_stream*zs)
{
fprintf(stderr, "%s: zlib error (%d): last zlib error: %s\n",
perror("errno:");
exit(1);
}
+#endif
static int reader_fileread(struct reader_t*reader, void* data, int len)
{
static int reader_zlibinflate(struct reader_t*reader, void* data, int len)
{
+#ifdef HAVE_ZLIB
struct zlibinflate_t*z = (struct zlibinflate_t*)reader->internal;
int ret;
if(!z)
}
reader->pos += len;
return len;
+#else
+ fprintf(stderr, "Error: swftools was compiled without zlib support");
+ exit(1);
+#endif
}
unsigned int reader_readbit(struct reader_t*r)
{
void writer_init_zlibdeflate(struct writer_t*w, struct writer_t*output)
{
+#ifdef HAVE_ZLIB
struct zlibdeflate_t*z;
int ret;
memset(w, 0, sizeof(struct writer_t));
w->mybyte = 0;
z->zs.next_out = z->writebuffer;
z->zs.avail_out = ZLIB_BUFFER_SIZE;
+#else
+ fprintf(stderr, "Error: swftools was compiled without zlib support");
+ exit(1);
+#endif
}
static int writer_zlibdeflate_write(struct writer_t*writer, void* data, int len)
{
+#ifdef HAVE_ZLIB
struct zlibdeflate_t*z = (struct zlibdeflate_t*)writer->internal;
int ret;
if(!z)
}
writer->pos += len;
return len;
+#else
+ fprintf(stderr, "Error: swftools was compiled without zlib support");
+ exit(1);
+#endif
}
static void writer_zlibdeflate_finish(struct writer_t*writer)
{
+#ifdef HAVE_ZLIB
struct zlibdeflate_t*z = (struct zlibdeflate_t*)writer->internal;
struct writer_t*output;
int ret;
free(writer->internal);
writer->internal = 0;
output->finish(output);
+#else
+ fprintf(stderr, "Error: swftools was compiled without zlib support");
+ exit(1);
+#endif
}
void writer_writebit(struct writer_t*w, int bit)