lzio.h 826 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. ** $Id: lzio.h,v 1.12 2002/06/06 12:40:22 roberto Exp roberto $
  3. ** Buffered streams
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef lzio_h
  7. #define lzio_h
  8. #include "lua.h"
  9. #define EOZ (-1) /* end of stream */
  10. typedef struct zio ZIO;
  11. #define zgetc(z) (((z)->n--)>0 ? \
  12. cast(int, cast(unsigned char, *(z)->p++)) : \
  13. luaZ_fill(z))
  14. #define zname(z) ((z)->name)
  15. void luaZ_init (ZIO *z, lua_Chunkreader reader, void *data, const char *name);
  16. size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
  17. int luaZ_lookahead (ZIO *z);
  18. /* --------- Private Part ------------------ */
  19. struct zio {
  20. size_t n; /* bytes still unread */
  21. const char *p; /* current position in buffer */
  22. lua_Chunkreader reader;
  23. void* data; /* additional data */
  24. const char *name;
  25. };
  26. int luaZ_fill (ZIO *z);
  27. #endif