1997-06-17 00:50:22 +08:00
|
|
|
/*
|
2002-04-29 20:37:41 +08:00
|
|
|
** $Id: lzio.h,v 1.8 2001/03/26 14:31:49 roberto Exp roberto $
|
1997-09-17 03:25:59 +08:00
|
|
|
** Buffered streams
|
|
|
|
** See Copyright Notice in lua.h
|
1997-06-17 00:50:22 +08:00
|
|
|
*/
|
|
|
|
|
1997-09-17 03:25:59 +08:00
|
|
|
|
|
|
|
#ifndef lzio_h
|
|
|
|
#define lzio_h
|
1997-06-17 00:50:22 +08:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
1997-06-19 04:30:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* For Lua only */
|
1997-06-20 02:55:28 +08:00
|
|
|
#define zFopen luaZ_Fopen
|
|
|
|
#define zmopen luaZ_mopen
|
|
|
|
#define zread luaZ_read
|
1997-06-19 04:30:52 +08:00
|
|
|
|
1997-06-17 00:50:22 +08:00
|
|
|
#define EOZ (-1) /* end of stream */
|
|
|
|
|
|
|
|
typedef struct zio ZIO;
|
|
|
|
|
1999-08-17 04:52:00 +08:00
|
|
|
ZIO* zFopen (ZIO* z, FILE* f, const char *name); /* open FILEs */
|
2000-05-24 21:54:49 +08:00
|
|
|
ZIO* zmopen (ZIO* z, const char* b, size_t size, const char *name); /* memory */
|
1997-06-17 00:50:22 +08:00
|
|
|
|
2000-05-24 21:54:49 +08:00
|
|
|
size_t zread (ZIO* z, void* b, size_t n); /* read next n bytes */
|
1997-06-19 05:39:56 +08:00
|
|
|
|
2000-05-24 21:54:49 +08:00
|
|
|
#define zgetc(z) (((z)->n--)>0 ? ((int)*(z)->p++): (z)->filbuf(z))
|
1997-12-23 04:57:18 +08:00
|
|
|
#define zname(z) ((z)->name)
|
1997-06-17 00:50:22 +08:00
|
|
|
|
|
|
|
|
2000-10-21 00:36:32 +08:00
|
|
|
|
1997-06-17 00:50:22 +08:00
|
|
|
/* --------- Private Part ------------------ */
|
|
|
|
|
2000-10-21 00:36:32 +08:00
|
|
|
#ifndef ZBSIZE
|
1997-06-17 00:50:22 +08:00
|
|
|
#define ZBSIZE 256 /* buffer size */
|
2000-10-21 00:36:32 +08:00
|
|
|
#endif
|
1997-06-17 00:50:22 +08:00
|
|
|
|
|
|
|
struct zio {
|
2000-05-24 21:54:49 +08:00
|
|
|
size_t n; /* bytes still unread */
|
1999-08-17 04:52:00 +08:00
|
|
|
const unsigned char* p; /* current position in buffer */
|
|
|
|
int (*filbuf)(ZIO* z);
|
|
|
|
void* u; /* additional data */
|
|
|
|
const char *name;
|
|
|
|
unsigned char buffer[ZBSIZE]; /* buffer */
|
1997-06-17 00:50:22 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|