lzio.h 836 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. ** $Id: lzio.h,v 1.9 2002/04/29 12:37:41 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. /* --------- Private Part ------------------ */
  20. struct zio {
  21. size_t n; /* bytes still unread */
  22. const char *p; /* current position in buffer */
  23. lua_Getblock getblock;
  24. void* ud; /* additional data */
  25. const char *name;
  26. };
  27. int luaZ_fill (ZIO *z);
  28. #endif