misc/liblua/lzio.h
author unc0rr
Mon, 19 Nov 2018 21:51:46 +0100
changeset 14249 06f2dc4deab2
parent 10017 de822cd3df3a
permissions -rw-r--r--
Remove erroneous code duplicating FIX_STRING functionality, adjust ansistring array size
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     1
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     2
** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     3
** Buffered streams
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     4
** See Copyright Notice in lua.h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     5
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     6
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     7
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     8
#ifndef lzio_h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     9
#define lzio_h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    10
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    11
#include "lua.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    12
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    13
#include "lmem.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    14
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    15
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    16
#define EOZ (-1)            /* end of stream */
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    17
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    18
typedef struct Zio ZIO;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    19
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    20
#define char2int(c) cast(int, cast(unsigned char, (c)))
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    21
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    22
#define zgetc(z)  (((z)->n--)>0 ?  char2int(*(z)->p++) : luaZ_fill(z))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    23
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    24
typedef struct Mbuffer {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    25
  char *buffer;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    26
  size_t n;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    27
  size_t buffsize;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    28
} Mbuffer;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    29
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    30
#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    31
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    32
#define luaZ_buffer(buff)   ((buff)->buffer)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    33
#define luaZ_sizebuffer(buff)   ((buff)->buffsize)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    34
#define luaZ_bufflen(buff)  ((buff)->n)
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    35
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    36
#define luaZ_resetbuffer(buff) ((buff)->n = 0)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    37
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    38
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    39
#define luaZ_resizebuffer(L, buff, size) \
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    40
    (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    41
    (buff)->buffsize = size)
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    42
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    43
#define luaZ_freebuffer(L, buff)    luaZ_resizebuffer(L, buff, 0)
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    44
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    45
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    46
LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    47
LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    48
                                        void *data);
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    49
LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    50
LUAI_FUNC int luaZ_lookahead (ZIO *z);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    51
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    52
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    53
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    54
/* --------- Private Part ------------------ */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    55
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    56
struct Zio {
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    57
  size_t n;         /* bytes still unread */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    58
  const char *p;        /* current position in buffer */
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    59
  lua_Reader reader;
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    60
  void* data;           /* additional data */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    61
  lua_State *L;         /* Lua state (for reader) */
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    62
};
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    63
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    64
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    65
LUAI_FUNC int luaZ_fill (ZIO *z);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    66
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    67
#endif