aboutsummaryrefslogtreecommitdiff
path: root/zio.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-09-16 16:25:59 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-09-16 16:25:59 -0300
commitd600a6b5b358c28d482b01f10bfa3292b17f5d12 (patch)
tree8f9047a23315351b32571092cade0883ace6f60e /zio.h
parent75ac0d217266dba48a887df96d37398140e22b9e (diff)
downloadlua-d600a6b5b358c28d482b01f10bfa3292b17f5d12.tar.gz
lua-d600a6b5b358c28d482b01f10bfa3292b17f5d12.tar.bz2
lua-d600a6b5b358c28d482b01f10bfa3292b17f5d12.zip
a generic input stream interface
Diffstat (limited to 'zio.h')
-rw-r--r--zio.h48
1 files changed, 0 insertions, 48 deletions
diff --git a/zio.h b/zio.h
deleted file mode 100644
index c688df55..00000000
--- a/zio.h
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2* zio.h
3* a generic input stream interface
4* $Id: zio.h,v 1.4 1997/06/19 18:55:28 roberto Exp roberto $
5*/
6
7#ifndef zio_h
8#define zio_h
9
10#include <stdio.h>
11
12
13
14/* For Lua only */
15#define zFopen luaZ_Fopen
16#define zsopen luaZ_sopen
17#define zmopen luaZ_mopen
18#define zread luaZ_read
19
20#define EOZ (-1) /* end of stream */
21
22typedef struct zio ZIO;
23
24ZIO* zFopen(ZIO* z, FILE* f); /* open FILEs */
25ZIO* zsopen(ZIO* z, char* s); /* string */
26ZIO* zmopen(ZIO* z, char* b, int size); /* memory */
27
28int zread(ZIO* z, void* b, int n); /* read next n bytes */
29
30#define zgetc(z) (--(z)->n>=0 ? ((int)*(z)->p++): (z)->filbuf(z))
31#define zungetc(z) (++(z)->n,--(z)->p)
32
33
34
35/* --------- Private Part ------------------ */
36
37#define ZBSIZE 256 /* buffer size */
38
39struct zio {
40 int n; /* bytes still unread */
41 unsigned char* p; /* current position in buffer */
42 int (*filbuf)(ZIO* z);
43 void* u; /* additional data */
44 unsigned char buffer[ZBSIZE]; /* buffer */
45};
46
47
48#endif