aboutsummaryrefslogtreecommitdiff
path: root/lzio.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2007-12-27 11:02:25 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2007-12-27 11:02:25 -0200
commitf5ae26ec6c2eb69f03f316e59c1e1977c52c7c23 (patch)
treeb4c761dac7648caea2cc20f8ebc2dd5b27a3fa1e /lzio.h
parent98194db4295726069137d13b8d24fca8cbf892b6 (diff)
downloadlua-f5ae26ec6c2eb69f03f316e59c1e1977c52c7c23.tar.gz
lua-f5ae26ec6c2eb69f03f316e59c1e1977c52c7c23.tar.bz2
lua-f5ae26ec6c2eb69f03f316e59c1e1977c52c7c23.zip
official branch for Lua 5.1
Diffstat (limited to 'lzio.h')
-rw-r--r--lzio.h67
1 files changed, 0 insertions, 67 deletions
diff --git a/lzio.h b/lzio.h
deleted file mode 100644
index 85843679..00000000
--- a/lzio.h
+++ /dev/null
@@ -1,67 +0,0 @@
1/*
2** $Id: lzio.h,v 1.20 2005/04/25 19:24:10 roberto Exp roberto $
3** Buffered streams
4** See Copyright Notice in lua.h
5*/
6
7
8#ifndef lzio_h
9#define lzio_h
10
11#include "lua.h"
12
13#include "lmem.h"
14
15
16#define EOZ (-1) /* end of stream */
17
18typedef struct Zio ZIO;
19
20#define char2int(c) cast(int, cast(unsigned char, (c)))
21
22#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z))
23
24typedef struct Mbuffer {
25 char *buffer;
26 size_t n;
27 size_t buffsize;
28} Mbuffer;
29
30#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
31
32#define luaZ_buffer(buff) ((buff)->buffer)
33#define luaZ_sizebuffer(buff) ((buff)->buffsize)
34#define luaZ_bufflen(buff) ((buff)->n)
35
36#define luaZ_resetbuffer(buff) ((buff)->n = 0)
37
38
39#define luaZ_resizebuffer(L, buff, size) \
40 (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
41 (buff)->buffsize = size)
42
43#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
44
45
46LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
47LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
48 void *data);
49LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
50LUAI_FUNC int luaZ_lookahead (ZIO *z);
51
52
53
54/* --------- Private Part ------------------ */
55
56struct Zio {
57 size_t n; /* bytes still unread */
58 const char *p; /* current position in buffer */
59 lua_Reader reader;
60 void* data; /* additional data */
61 lua_State *L; /* Lua state (for reader) */
62};
63
64
65LUAI_FUNC int luaZ_fill (ZIO *z);
66
67#endif