lzio.h 866 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. ** $Id: lzio.h,v 1.10 2002/06/03 17:46:34 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. /* For Lua only */
  10. #define zread luaZ_zread
  11. #define EOZ (-1) /* end of stream */
  12. typedef struct zio ZIO;
  13. #define zgetc(z) (((z)->n--)>0 ? \
  14. cast(int, cast(unsigned char, *(z)->p++)) : \
  15. luaZ_fill(z))
  16. #define zname(z) ((z)->name)
  17. void luaZ_init (ZIO *z, lua_Getblock getblock, void *ud, const char *name);
  18. size_t luaZ_zread (ZIO* z, void* b, size_t n); /* read next n bytes */
  19. int luaZ_lookahead (ZIO *z);
  20. /* --------- Private Part ------------------ */
  21. struct zio {
  22. size_t n; /* bytes still unread */
  23. const char *p; /* current position in buffer */
  24. lua_Getblock getblock;
  25. void* ud; /* additional data */
  26. const char *name;
  27. };
  28. int luaZ_fill (ZIO *z);
  29. #endif