48 lines
951 B
C
Raw Normal View History

2003-08-15 18:00:22 +00:00
/*
** Buffered streams
** See Copyright Notice in lua.h
*/
2009-05-26 09:39:42 +00:00
#ifndef GRIM_LZIO_H
#define GRIM_LZIO_H
2003-08-15 18:00:22 +00:00
2011-04-27 20:45:07 +02:00
#include "common/scummsys.h"
2003-08-15 18:00:22 +00:00
2008-07-28 14:51:57 +00:00
namespace Common {
class File;
}
2003-08-15 18:00:22 +00:00
2009-05-25 06:49:57 +00:00
namespace Grim {
2008-07-28 14:51:57 +00:00
// For Lua only
2022-01-06 18:26:30 +01:00
#define zopen luaZ_mopen
2003-08-15 18:00:22 +00:00
2022-01-06 18:26:30 +01:00
#define EOZ (-1) // end of stream
2003-08-15 18:00:22 +00:00
typedef struct zio ZIO;
2008-07-28 14:51:57 +00:00
ZIO *zopen(ZIO *z, const char *b, int32 size, const char *name);
2022-01-06 18:26:30 +01:00
int32 zread(ZIO *z, void *b, int32 n); // read next n bytes
2008-07-28 14:51:57 +00:00
int32 zgeteoz(ZIO *);
2003-08-15 18:00:22 +00:00
2022-01-06 18:26:30 +01:00
#define zgetc(z) (--(z)->n >= 0 ? ((int32)*(z)->p++): zgeteoz(z))
#define zungetc(z) (++(z)->n, --(z)->p)
#define zname(z) ((z)->name)
2003-08-15 18:00:22 +00:00
2008-07-28 14:51:57 +00:00
// --------- Private Part ------------------
2003-08-15 18:00:22 +00:00
2022-01-06 18:26:30 +01:00
#define ZBSIZE 256 // buffer size
2003-08-15 18:00:22 +00:00
struct zio {
2022-01-06 18:26:30 +01:00
int32 n; // bytes still unread
const byte *p; // current position in buffer
2008-07-28 14:51:57 +00:00
const char *name;
2022-01-06 18:26:30 +01:00
byte buffer[ZBSIZE]; // buffer
2003-08-15 18:00:22 +00:00
};
2009-05-25 06:49:57 +00:00
} // end of namespace Grim
2003-08-15 18:00:22 +00:00
#endif