lua/lzio.h

51 lines
1.1 KiB
C
Raw Normal View History

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