summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/util/lua/src/lzio.h
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-04-14 13:01:55 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-04-14 13:01:55 +0000
commit926c8ad88a5cce707fe1025f3551aa1c03318b32 (patch)
tree9d0c7d3102578adca5ab7381e3b1296f218270f8 /crawl-ref/source/util/lua/src/lzio.h
parent72560e17acd9fd40a9dcc969c14f3b1fd60fe96c (diff)
downloadcrawl-ref-926c8ad88a5cce707fe1025f3551aa1c03318b32.tar.gz
crawl-ref-926c8ad88a5cce707fe1025f3551aa1c03318b32.zip
Included Lua 5.1.2 source tree in crawl-ref/source/util. This is so we can use
Lua in core Crawl code without making Crawl harder to build (than it is already). Crawl's makefiles will call the Lua makefile if necessary (i.e., if liblua.a doesn't already exist). CLUA_BINDINGS is still not enabled by default (and will not be enabled by default in the source tree). Crawl will use two different Lua interpreter instances - one for user scripts (if CLUA_BINDINGS is defined), the other (not #ifdef conditionalised) for core game Lua glue. Lua is statically linked by default. We could change this if necessary, although the added size is only 200k. The Lua sources are almost unmodified; I've only added new targets for Crawl's platform-specific makefiles to call into to build liblua.a; I've not modified any existing targets, and all Lua READMEs and copyright notices are intact. Needs integration with Xcode build. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1305 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/util/lua/src/lzio.h')
-rw-r--r--crawl-ref/source/util/lua/src/lzio.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/crawl-ref/source/util/lua/src/lzio.h b/crawl-ref/source/util/lua/src/lzio.h
new file mode 100644
index 0000000000..8f403b8e74
--- /dev/null
+++ b/crawl-ref/source/util/lua/src/lzio.h
@@ -0,0 +1,67 @@
+/*
+** $Id: lzio.h,v 1.21 2005/05/17 19:49:15 roberto Exp $
+** Buffered streams
+** See Copyright Notice in lua.h
+*/
+
+
+#ifndef lzio_h
+#define lzio_h
+
+#include "lua.h"
+
+#include "lmem.h"
+
+
+#define EOZ (-1) /* end of stream */
+
+typedef struct Zio ZIO;
+
+#define char2int(c) cast(int, cast(unsigned char, (c)))
+
+#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z))
+
+typedef struct Mbuffer {
+ char *buffer;
+ size_t n;
+ size_t buffsize;
+} Mbuffer;
+
+#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
+
+#define luaZ_buffer(buff) ((buff)->buffer)
+#define luaZ_sizebuffer(buff) ((buff)->buffsize)
+#define luaZ_bufflen(buff) ((buff)->n)
+
+#define luaZ_resetbuffer(buff) ((buff)->n = 0)
+
+
+#define luaZ_resizebuffer(L, buff, size) \
+ (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
+ (buff)->buffsize = size)
+
+#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
+
+
+LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
+LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
+ void *data);
+LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
+LUAI_FUNC int luaZ_lookahead (ZIO *z);
+
+
+
+/* --------- Private Part ------------------ */
+
+struct Zio {
+ size_t n; /* bytes still unread */
+ const char *p; /* current position in buffer */
+ lua_Reader reader;
+ void* data; /* additional data */
+ lua_State *L; /* Lua state (for reader) */
+};
+
+
+LUAI_FUNC int luaZ_fill (ZIO *z);
+
+#endif