summaryrefslogtreecommitdiff
path: root/src/gd_io.h
blob: ed02d25735c3c6e53a6c91654c5347eb403874af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifdef __cplusplus
extern "C" {
#endif

#ifndef GD_IO_H
#define GD_IO_H 1

#include <stdio.h>

#ifdef VMS
#	define Putchar gdPutchar
#endif

	typedef struct gdIOCtx {
		int (*getC)(struct gdIOCtx *);
		int (*getBuf)(struct gdIOCtx *, void *, int);
		void (*putC)(struct gdIOCtx *, int);
		int (*putBuf)(struct gdIOCtx *, const void *, int);
		/* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */
		int (*seek)(struct gdIOCtx *, const int);
		long (*tell)(struct gdIOCtx *);
		void (*gd_free)(struct gdIOCtx *);
		void *data;
	}
	gdIOCtx;

	typedef struct gdIOCtx *gdIOCtxPtr;

	void Putword(int w, gdIOCtx *ctx);
	void Putchar(int c, gdIOCtx *ctx);

	void gdPutC(const unsigned char c, gdIOCtx *ctx);
	int gdPutBuf(const void *, int, gdIOCtx *);
	void gdPutWord(int w, gdIOCtx *ctx);
	void gdPutInt(int w, gdIOCtx *ctx);

	int gdGetC(gdIOCtx *ctx);
	int gdGetBuf(void *, int, gdIOCtx *);
	int gdGetByte(int *result, gdIOCtx *ctx);
	int gdGetWord(int *result, gdIOCtx *ctx);
	int gdGetWordLSB(signed short int *result, gdIOCtx *ctx);
	int gdGetInt(int *result, gdIOCtx *ctx);
	int gdGetIntLSB(signed int *result, gdIOCtx *ctx);

	int gdSeek(gdIOCtx *ctx, const int offset);
	long gdTell(gdIOCtx *ctx);

#endif

#ifdef __cplusplus
}
#endif