aboutsummaryrefslogtreecommitdiff
path: root/lzio.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-06-03 14:46:34 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-06-03 14:46:34 -0300
commit35a22ed1ab15fabb9404d0184165baa1d52394f1 (patch)
tree2dc281a4897de0eac364fa15695d11db030cd079 /lzio.h
parentff91b355f451c7b7fc286d8ca9bc8613096f497d (diff)
downloadlua-35a22ed1ab15fabb9404d0184165baa1d52394f1.tar.gz
lua-35a22ed1ab15fabb9404d0184165baa1d52394f1.tar.bz2
lua-35a22ed1ab15fabb9404d0184165baa1d52394f1.zip
lua_load* replaced by a simple lua_load
Diffstat (limited to 'lzio.h')
-rw-r--r--lzio.h34
1 files changed, 14 insertions, 20 deletions
diff --git a/lzio.h b/lzio.h
index 283fdc38..9ffbbf8a 100644
--- a/lzio.h
+++ b/lzio.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lzio.h,v 1.8 2001/03/26 14:31:49 roberto Exp roberto $ 2** $Id: lzio.h,v 1.9 2002/04/29 12:37:41 roberto Exp roberto $
3** Buffered streams 3** Buffered streams
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -8,43 +8,37 @@
8#ifndef lzio_h 8#ifndef lzio_h
9#define lzio_h 9#define lzio_h
10 10
11#include <stdio.h> 11#include "lua.h"
12
13 12
14 13
15/* For Lua only */ 14/* For Lua only */
16#define zFopen luaZ_Fopen 15#define zread luaZ_zread
17#define zmopen luaZ_mopen
18#define zread luaZ_read
19 16
20#define EOZ (-1) /* end of stream */ 17#define EOZ (-1) /* end of stream */
21 18
22typedef struct zio ZIO; 19typedef struct zio ZIO;
23 20
24ZIO* zFopen (ZIO* z, FILE* f, const char *name); /* open FILEs */ 21#define zgetc(z) (((z)->n--)>0 ? \
25ZIO* zmopen (ZIO* z, const char* b, size_t size, const char *name); /* memory */ 22 cast(int, cast(unsigned char, *(z)->p++)) : \
26 23 luaZ_fill(z))
27size_t zread (ZIO* z, void* b, size_t n); /* read next n bytes */
28 24
29#define zgetc(z) (((z)->n--)>0 ? ((int)*(z)->p++): (z)->filbuf(z))
30#define zname(z) ((z)->name) 25#define zname(z) ((z)->name)
31 26
27void luaZ_init (ZIO *z, lua_Getblock getblock, void *ud, const char *name);
28size_t luaZ_zread (ZIO* z, void* b, size_t n); /* read next n bytes */
32 29
33 30
34/* --------- Private Part ------------------ */ 31/* --------- Private Part ------------------ */
35 32
36#ifndef ZBSIZE
37#define ZBSIZE 256 /* buffer size */
38#endif
39
40struct zio { 33struct zio {
41 size_t n; /* bytes still unread */ 34 size_t n; /* bytes still unread */
42 const unsigned char* p; /* current position in buffer */ 35 const char *p; /* current position in buffer */
43 int (*filbuf)(ZIO* z); 36 lua_Getblock getblock;
44 void* u; /* additional data */ 37 void* ud; /* additional data */
45 const char *name; 38 const char *name;
46 unsigned char buffer[ZBSIZE]; /* buffer */
47}; 39};
48 40
49 41
42int luaZ_fill (ZIO *z);
43
50#endif 44#endif