OSDN Git Service

Since the nios2 port is the only one to use the get_gp_value() function,
[uclinux-h8/elf2flt.git] / compress.h
1 /*
2  * Helper functions to handle compression via zlib
3  *
4  * Copyright (C) 2007-2008 Julian Brown
5  * Copyright (C) 2008 Mike Frysinger
6  *
7  * Licensed under the GPL-2 or later.
8  */
9
10 #ifndef __ELF2FLT_COMPRESS_H__
11 #define __ELF2FLT_COMPRESS_H__
12
13 #include <zlib.h>
14
15 typedef enum
16 {
17   INVALID,
18   UNCOMPRESSED,
19   COMPRESSED
20 } stream_type;
21
22 /* Tagged union holding either a regular FILE* handle or a zlib gzFile
23    handle.  */
24 typedef struct
25 {
26   stream_type type;
27   const char *mode;
28   union
29     {
30       FILE *filep;
31       gzFile gzfilep;
32     } u;
33 } stream;
34
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 int fseek_stream(stream *str, long offset, int whence);
41 void reopen_stream_compressed(stream *str);
42 void transfer(stream *ifp, stream *ofp, int count);
43
44 #endif