2017-06-09 06:39:37 +00:00
|
|
|
#ifndef XMP_HIO_H
|
|
|
|
#define XMP_HIO_H
|
|
|
|
|
2018-10-29 06:34:25 +00:00
|
|
|
#ifdef EDUKE32_DISABLED
|
2017-06-09 06:39:37 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2018-10-29 06:34:25 +00:00
|
|
|
#endif
|
2017-06-09 06:39:37 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
#include "memio.h"
|
|
|
|
|
|
|
|
#define HIO_HANDLE_TYPE(x) ((x)->type)
|
|
|
|
|
|
|
|
typedef struct {
|
2018-10-29 06:34:25 +00:00
|
|
|
#ifdef EDUKE32_DISABLED
|
2017-06-09 06:39:37 +00:00
|
|
|
#define HIO_HANDLE_TYPE_FILE 0
|
2018-10-29 06:34:25 +00:00
|
|
|
#endif
|
2017-06-09 06:39:37 +00:00
|
|
|
#define HIO_HANDLE_TYPE_MEMORY 1
|
|
|
|
int type;
|
|
|
|
long size;
|
|
|
|
union {
|
2018-10-29 06:34:25 +00:00
|
|
|
#ifdef EDUKE32_DISABLED
|
2017-06-09 06:39:37 +00:00
|
|
|
FILE *file;
|
2018-10-29 06:34:25 +00:00
|
|
|
#endif
|
2017-06-09 06:39:37 +00:00
|
|
|
MFILE *mem;
|
|
|
|
} handle;
|
|
|
|
int error;
|
|
|
|
} HIO_HANDLE;
|
|
|
|
|
|
|
|
int8 hio_read8s (HIO_HANDLE *);
|
|
|
|
uint8 hio_read8 (HIO_HANDLE *);
|
|
|
|
uint16 hio_read16l (HIO_HANDLE *);
|
|
|
|
uint16 hio_read16b (HIO_HANDLE *);
|
|
|
|
uint32 hio_read24l (HIO_HANDLE *);
|
|
|
|
uint32 hio_read24b (HIO_HANDLE *);
|
|
|
|
uint32 hio_read32l (HIO_HANDLE *);
|
|
|
|
uint32 hio_read32b (HIO_HANDLE *);
|
|
|
|
size_t hio_read (void *, size_t, size_t, HIO_HANDLE *);
|
|
|
|
int hio_seek (HIO_HANDLE *, long, int);
|
|
|
|
long hio_tell (HIO_HANDLE *);
|
|
|
|
int hio_eof (HIO_HANDLE *);
|
|
|
|
int hio_error (HIO_HANDLE *);
|
2018-10-29 06:34:25 +00:00
|
|
|
#ifdef EDUKE32_DISABLED
|
2017-06-09 06:39:37 +00:00
|
|
|
HIO_HANDLE *hio_open (const void *, const char *);
|
2018-10-29 06:34:25 +00:00
|
|
|
#endif
|
2017-06-09 06:39:37 +00:00
|
|
|
HIO_HANDLE *hio_open_mem (const void *, long);
|
2018-10-29 06:34:25 +00:00
|
|
|
#ifdef EDUKE32_DISABLED
|
2017-06-09 06:39:37 +00:00
|
|
|
HIO_HANDLE *hio_open_file (FILE *);
|
2018-10-29 06:34:25 +00:00
|
|
|
#endif
|
2017-06-09 06:39:37 +00:00
|
|
|
int hio_close (HIO_HANDLE *);
|
|
|
|
long hio_size (HIO_HANDLE *);
|
|
|
|
|
|
|
|
#endif
|