~widelands-dev/widelands/remove-savegame-compatibility-after-economy-change

« back to all changes in this revision

Viewing changes to src/third_party/eris/lzio.h

Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
** See Copyright Notice in lua.h
5
5
*/
6
6
 
 
7
 
7
8
#ifndef lzio_h
8
9
#define lzio_h
9
10
 
11
12
 
12
13
#include "lmem.h"
13
14
 
14
 
#define EOZ (-1) /* end of stream */
 
15
 
 
16
#define EOZ     (-1)                    /* end of stream */
15
17
 
16
18
typedef struct Zio ZIO;
17
19
 
18
 
#define zgetc(z) (((z)->n--) > 0 ? cast_uchar(*(z)->p++) : luaZ_fill(z))
 
20
#define zgetc(z)  (((z)->n--)>0 ?  cast_uchar(*(z)->p++) : luaZ_fill(z))
 
21
 
19
22
 
20
23
typedef struct Mbuffer {
21
 
        char* buffer;
22
 
        size_t n;
23
 
        size_t buffsize;
 
24
  char *buffer;
 
25
  size_t n;
 
26
  size_t buffsize;
24
27
} Mbuffer;
25
28
 
26
29
#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
27
30
 
28
 
#define luaZ_buffer(buff) ((buff)->buffer)
29
 
#define luaZ_sizebuffer(buff) ((buff)->buffsize)
30
 
#define luaZ_bufflen(buff) ((buff)->n)
 
31
#define luaZ_buffer(buff)       ((buff)->buffer)
 
32
#define luaZ_sizebuffer(buff)   ((buff)->buffsize)
 
33
#define luaZ_bufflen(buff)      ((buff)->n)
31
34
 
32
 
#define luaZ_buffremove(buff, i) ((buff)->n -= (i))
 
35
#define luaZ_buffremove(buff,i) ((buff)->n -= (i))
33
36
#define luaZ_resetbuffer(buff) ((buff)->n = 0)
34
37
 
35
 
#define luaZ_resizebuffer(L, buff, size)                                                           \
36
 
        ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, (buff)->buffsize, size),                 \
37
 
         (buff)->buffsize = size)
38
 
 
39
 
#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
40
 
 
41
 
LUAI_FUNC void luaZ_init(lua_State* L, ZIO* z, lua_Reader reader, void* data);
42
 
LUAI_FUNC size_t luaZ_read(ZIO* z, void* b, size_t n); /* read next n bytes */
 
38
 
 
39
#define luaZ_resizebuffer(L, buff, size) \
 
40
        ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \
 
41
                                (buff)->buffsize, size), \
 
42
        (buff)->buffsize = size)
 
43
 
 
44
#define luaZ_freebuffer(L, buff)        luaZ_resizebuffer(L, buff, 0)
 
45
 
 
46
 
 
47
LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
 
48
                                        void *data);
 
49
LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */
 
50
 
 
51
 
43
52
 
44
53
/* --------- Private Part ------------------ */
45
54
 
46
55
struct Zio {
47
 
        size_t n;          /* bytes still unread */
48
 
        const char* p;     /* current position in buffer */
49
 
        lua_Reader reader; /* reader function */
50
 
        void* data;        /* additional data */
51
 
        lua_State* L;      /* Lua state (for reader) */
 
56
  size_t n;                     /* bytes still unread */
 
57
  const char *p;                /* current position in buffer */
 
58
  lua_Reader reader;            /* reader function */
 
59
  void *data;                   /* additional data */
 
60
  lua_State *L;                 /* Lua state (for reader) */
52
61
};
53
62
 
54
 
LUAI_FUNC int luaZ_fill(ZIO* z);
 
63
 
 
64
LUAI_FUNC int luaZ_fill (ZIO *z);
55
65
 
56
66
#endif