lua/lzio.h

46 lines
872 B
C
Raw Normal View History

1997-06-16 20:50:22 +04:00
/*
2002-06-06 16:40:22 +04:00
** $Id: lzio.h,v 1.11 2002/06/03 20:11:07 roberto Exp roberto $
1997-09-16 23:25:59 +04:00
** Buffered streams
** See Copyright Notice in lua.h
1997-06-16 20:50:22 +04:00
*/
1997-09-16 23:25:59 +04:00
#ifndef lzio_h
#define lzio_h
1997-06-16 20:50:22 +04:00
#include "lua.h"
/* For Lua only */
#define zread luaZ_zread
1997-06-16 20:50:22 +04:00
#define EOZ (-1) /* end of stream */
typedef struct zio ZIO;
#define zgetc(z) (((z)->n--)>0 ? \
cast(int, cast(unsigned char, *(z)->p++)) : \
luaZ_fill(z))
1997-06-19 01:39:56 +04:00
1997-12-22 23:57:18 +03:00
#define zname(z) ((z)->name)
1997-06-16 20:50:22 +04:00
2002-06-06 16:40:22 +04:00
void luaZ_init (ZIO *z, lua_Chunkreader reader, void *data, const char *name);
size_t luaZ_zread (ZIO* z, void* b, size_t n); /* read next n bytes */
2002-06-04 00:11:07 +04:00
int luaZ_lookahead (ZIO *z);
1997-06-16 20:50:22 +04:00
2000-10-20 20:36:32 +04:00
1997-06-16 20:50:22 +04:00
/* --------- Private Part ------------------ */
struct zio {
size_t n; /* bytes still unread */
const char *p; /* current position in buffer */
2002-06-06 16:40:22 +04:00
lua_Chunkreader reader;
void* data; /* additional data */
1999-08-17 00:52:00 +04:00
const char *name;
1997-06-16 20:50:22 +04:00
};
int luaZ_fill (ZIO *z);
1997-06-16 20:50:22 +04:00
#endif