lua/lzio.h

51 lines
1.0 KiB
C
Raw Normal View History

1997-06-16 20:50:22 +04:00
/*
1997-12-22 23:57:18 +03:00
** $Id: lzio.h,v 1.2 1997/11/21 19:00:46 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>
/* 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-16 20:50:22 +04:00
#define EOZ (-1) /* end of stream */
typedef struct zio ZIO;
1997-12-22 23:57:18 +03:00
ZIO* zFopen (ZIO* z, FILE* f, char *name); /* open FILEs */
ZIO* zsopen (ZIO* z, char* s, char *name); /* string */
ZIO* zmopen (ZIO* z, char* b, int size, char *name); /* memory */
1997-06-16 20:50:22 +04:00
int zread (ZIO* z, void* b, int n); /* read next n bytes */
1997-06-19 01:39:56 +04:00
1997-06-16 20:50:22 +04:00
#define zgetc(z) (--(z)->n>=0 ? ((int)*(z)->p++): (z)->filbuf(z))
#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
/* --------- Private Part ------------------ */
#define ZBSIZE 256 /* buffer size */
struct zio {
int n; /* bytes still unread */
unsigned char* p; /* current position in buffer */
int (*filbuf)(ZIO* z);
void* u; /* additional data */
unsigned char buffer[ZBSIZE]; /* buffer */
1997-12-22 23:57:18 +03:00
char *name;
1997-06-16 20:50:22 +04:00
};
#endif