1997-06-16 20:50:22 +04:00
|
|
|
/*
|
2000-10-20 20:36:32 +04:00
|
|
|
** $Id: lzio.h,v 1.6 2000/05/24 13:54:49 roberto Exp roberto $
|
1997-09-16 23:25:59 +04:00
|
|
|
** Buffered streams
|
|
|
|
** See Copyright Notice in lua.h
|
1997-06-16 20:50:22 +04:00
|
|
|
*/
|
|
|
|
|
1997-09-16 23:25:59 +04:00
|
|
|
|
|
|
|
#ifndef lzio_h
|
|
|
|
#define lzio_h
|
1997-06-16 20:50:22 +04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
1997-06-19 00:30:52 +04:00
|
|
|
|
|
|
|
|
|
|
|
/* For Lua only */
|
1997-06-19 22:55:28 +04:00
|
|
|
#define zFopen luaZ_Fopen
|
|
|
|
#define zsopen luaZ_sopen
|
|
|
|
#define zmopen luaZ_mopen
|
|
|
|
#define zread luaZ_read
|
1997-06-19 00:30:52 +04:00
|
|
|
|
1997-06-16 20:50:22 +04:00
|
|
|
#define EOZ (-1) /* end of stream */
|
|
|
|
|
|
|
|
typedef struct zio ZIO;
|
|
|
|
|
1999-08-17 00:52:00 +04:00
|
|
|
ZIO* zFopen (ZIO* z, FILE* f, const char *name); /* open FILEs */
|
|
|
|
ZIO* zsopen (ZIO* z, const char* s, const char *name); /* string */
|
2000-05-24 17:54:49 +04:00
|
|
|
ZIO* zmopen (ZIO* z, const char* b, size_t size, const char *name); /* memory */
|
1997-06-16 20:50:22 +04:00
|
|
|
|
2000-05-24 17:54:49 +04:00
|
|
|
size_t zread (ZIO* z, void* b, size_t n); /* read next n bytes */
|
1997-06-19 01:39:56 +04:00
|
|
|
|
2000-05-24 17:54:49 +04:00
|
|
|
#define zgetc(z) (((z)->n--)>0 ? ((int)*(z)->p++): (z)->filbuf(z))
|
1997-06-16 20:50:22 +04:00
|
|
|
#define zungetc(z) (++(z)->n,--(z)->p)
|
1997-12-22 23:57:18 +03:00
|
|
|
#define zname(z) ((z)->name)
|
1997-06-16 20:50:22 +04:00
|
|
|
|
|
|
|
|
2000-10-20 20:36:32 +04:00
|
|
|
|
1997-06-16 20:50:22 +04:00
|
|
|
/* --------- Private Part ------------------ */
|
|
|
|
|
2000-10-20 20:36:32 +04:00
|
|
|
#ifndef ZBSIZE
|
1997-06-16 20:50:22 +04:00
|
|
|
#define ZBSIZE 256 /* buffer size */
|
2000-10-20 20:36:32 +04:00
|
|
|
#endif
|
1997-06-16 20:50:22 +04:00
|
|
|
|
|
|
|
struct zio {
|
2000-05-24 17:54:49 +04:00
|
|
|
size_t n; /* bytes still unread */
|
1999-08-17 00:52:00 +04: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-16 20:50:22 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|