Statistics
| Revision:

gvsig-raster / libjni-potrace / trunk / libjni-potrace / resources / potrace-1.8 / src / lzw.h @ 1780

History | View | Annotate | Download (2.36 KB)

1
/* Copyright (C) 2001-2007 Peter Selinger.
2
   This file is part of Potrace. It is free software and it is covered
3
   by the GNU General Public License. See the file COPYING for details. */
4

    
5
/* $Id: lzw.h 147 2007-04-09 00:44:09Z selinger $ */
6

    
7
#define LZW_NORMAL 0
8
#define LZW_EOD 1
9

    
10
/* user visible state */
11

    
12
struct lzw_stream_s {
13
  char *next_in;     /* pointer to next input character */
14
  int avail_in;      /* number of input chars available */
15
  char *next_out;    /* pointer to next free byte in output buffer */
16
  int avail_out;     /* remaining size of output buffer */
17

    
18
  void *internal;    /* internal state, not user accessible */
19
};
20
typedef struct lzw_stream_s lzw_stream_t;
21

    
22
/* user visible functions */
23

    
24
/* The interface for compression and decompression is the same.  The
25
   application must first call lzw_init to create and initialize a
26
   compression object.  Then it calls lzw_compress on this object
27
   repeatedly, as follows: next_in and next_out must point to valid,
28
   non-overlapping regions of memory of size at least avail_in and
29
   avail_out, respectively.  The lzw_compress function will read and
30
   process as many input bytes as possible as long as there is room in
31
   the output buffer. It will update next_in, avail_in, next_out, and
32
   avail_out accordingly. Some input may be consumed without producing
33
   any output, or some output may be produced without consuming any
34
   input. However, the lzw_compress function makes progress in the
35
   sense that, after calling this function, at least one of avail_in
36
   or avail_out is guaranteed to be 0. The mode flag is normally set
37
   to LZW_NORMAL. It can be set to LZW_EOD (end of data) to indicate
38
   that the current input buffer represents the entire remaining input
39
   data stream.  When called with mode=LZW_EOD, and avail_out is
40
   non-zero after the call, then the application may conclude that the
41
   end of output has been reached. (However, if avail_out==0 after the
42
   call, then lzw_compress should be called again with the remaining
43
   input, if any). Finally, lzw_free should be called to deallocate
44
   the lzw_stream. Lzw_init returns NULL on error, with errno
45
   set. Lzw_compress returns 0 on success, and 1 on error with errno
46
   set. EINVAL is used to indicate an internal error, which should not
47
   happen. */
48

    
49
lzw_stream_t *lzw_init(void);
50
int lzw_compress(lzw_stream_t *s, int mode);
51
void lzw_free(lzw_stream_t *s);