lua/lzio.h

Go to the documentation of this file.
00001 /*
00002 ** $Id: lzio.h,v 1.2 2004/03/23 05:09:14 jbj Exp $
00003 ** Buffered streams
00004 ** See Copyright Notice in lua.h
00005 */
00006 
00007 
00008 #ifndef lzio_h
00009 #define lzio_h
00010 
00011 #include "lua.h"
00012 
00013 
00014 #define EOZ     (-1)                    /* end of stream */
00015 
00016 typedef struct Zio ZIO;
00017 
00018 
00019 #define char2int(c)     cast(int, cast(unsigned char, (c)))
00020 
00021 #define zgetc(z)  (((z)->n--)>0 ?  char2int(*(z)->p++) : luaZ_fill(z))
00022 
00023 #define zname(z)        ((z)->name)
00024 
00025 void luaZ_init (ZIO *z, lua_Chunkreader reader, void *data, const char *name)
00026         /*@modifies z @*/;
00027 size_t luaZ_read (ZIO* z, void* b, size_t n)    /* read next n bytes */
00028         /*@modifies z, *b @*/;
00029 int luaZ_lookahead (ZIO *z)
00030         /*@modifies z @*/;
00031 
00032 
00033 
00034 typedef struct Mbuffer {
00035 /*@relnull@*/
00036   char *buffer;
00037   size_t buffsize;
00038 } Mbuffer;
00039 
00040 
00041 char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n)
00042         /*@modifies L, buff @*/;
00043 
00044 #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
00045 
00046 #define luaZ_sizebuffer(buff)   ((buff)->buffsize)
00047 #define luaZ_buffer(buff)       ((buff)->buffer)
00048 
00049 #define luaZ_resizebuffer(L, buff, size) \
00050         (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
00051         (buff)->buffsize = size)
00052 
00053 #define luaZ_freebuffer(L, buff)        luaZ_resizebuffer(L, buff, 0)
00054 
00055 
00056 /* --------- Private Part ------------------ */
00057 
00058 struct Zio {
00059   size_t n;                     /* bytes still unread */
00060 /*@relnull@*/
00061   const char *p;                /* current position in buffer */
00062   lua_Chunkreader reader;
00063   void* data;                   /* additional data */
00064   const char *name;
00065 };
00066 
00067 
00068 int luaZ_fill (ZIO *z)
00069         /*@modifies z @*/;
00070 
00071 #endif

Generated on Fri Oct 12 08:44:54 2007 for rpm by  doxygen 1.5.2