pull from upstream
[buildroot.git] / toolchain / elf2flt / elf2flt / compress.h
blobd27f70853e1759082c68a141f35d0e7dbdc0218e
1 /*
2 * Helper functions to handle compression via zlib
4 * Copyright (C) 2007-2008 Julian Brown
5 * Copyright (C) 2008 Mike Frysinger
7 * Licensed under the GPL-2 or later.
8 */
10 #ifndef __ELF2FLT_COMPRESS_H__
11 #define __ELF2FLT_COMPRESS_H__
13 #include <zlib.h>
15 typedef enum
17 INVALID,
18 UNCOMPRESSED,
19 COMPRESSED
20 } stream_type;
22 /* Tagged union holding either a regular FILE* handle or a zlib gzFile
23 handle. */
24 typedef struct
26 stream_type type;
27 const char *mode;
28 union
30 FILE *filep;
31 gzFile gzfilep;
32 } u;
33 } stream;
35 int fopen_stream_u(stream *fp, const char *path, const char *mode);
36 size_t fread_stream(void *ptr, size_t size, size_t nmemb, stream *str);
37 size_t fwrite_stream(const void *ptr, size_t size, size_t nmemb, stream *str);
38 int fclose_stream(stream *str);
39 int ferror_stream(stream *str);
40 void reopen_stream_compressed(stream *str);
41 void transfer(stream *ifp, stream *ofp, int count);
43 #endif