Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
445 theseven 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
 
447 theseven 13
//#include <zlib.h>
445 theseven 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;
447 theseven 28
  FILE *filep;
29
  char* buffer;
30
  int bufsize;
31
  int bufused;
32
//  union
33
//    {
34
//      FILE *filep;
35
//      gzFile gzfilep;
36
//    } u;
445 theseven 37
} stream;
38
 
39
int fopen_stream_u(stream *fp, const char *path, const char *mode);
40
size_t fread_stream(void *ptr, size_t size, size_t nmemb, stream *str);
41
size_t fwrite_stream(const void *ptr, size_t size, size_t nmemb, stream *str);
42
int fclose_stream(stream *str);
43
int ferror_stream(stream *str);
44
int fseek_stream(stream *str, long offset, int whence);
45
void reopen_stream_compressed(stream *str);
46
void transfer(stream *ifp, stream *ofp, int count);
47
 
48
#endif