add kread_and_test and cached1d enum from mainline

parent d83cb7fc
......@@ -10,6 +10,14 @@
extern "C" {
#endif
enum cachelock_t
{
CACHE1D_FREE = 1,
CACHE1D_UNLOCKED = 199,
CACHE1D_LOCKED = 200,
CACHE1D_PERMANENT = 255,
};
void cacheInitBuffer(intptr_t dacachestart, int dacachesize);
void cacheAllocateBlock(intptr_t *newhandle, int newbytes, char *newlockptr);
void suckcache(intptr_t *suckptr);
......@@ -26,6 +34,7 @@ void uninitsinglegroupfile(int grphandle);
void uninitgroupfile(void);
int kopen4load(char *filename, char searchfirst); // searchfirst: 0 = anywhere, 1 = first group, 2 = any group
int kread(int handle, void *buffer, int leng);
#define kread_and_test(handle, buffer, leng) EDUKE32_PREDICT_FALSE(kread((handle), (buffer), (leng)) != (leng))
int klseek(int handle, int offset, int whence);
#define klseek_and_test(handle, offset, whence) EDUKE32_PREDICT_FALSE(klseek((handle), (offset), (whence)) < 0)
int kfilelength(int handle);
......@@ -33,23 +42,23 @@ int ktell(int handle);
void kclose(int handle);
enum {
CACHE1D_FIND_FILE = 1,
CACHE1D_FIND_DIR = 2,
CACHE1D_FIND_DRIVE = 4,
CACHE1D_FIND_FILE = 1,
CACHE1D_FIND_DIR = 2,
CACHE1D_FIND_DRIVE = 4,
CACHE1D_OPT_NOSTACK = 0x100,
// the lower the number, the higher the priority
CACHE1D_SOURCE_DRIVE = 0,
CACHE1D_SOURCE_CURDIR = 1,
CACHE1D_SOURCE_PATH = 2, // + path stack depth
CACHE1D_SOURCE_ZIP = 0x7ffffffe,
CACHE1D_SOURCE_GRP = 0x7fffffff,
CACHE1D_OPT_NOSTACK = 0x100,
// the lower the number, the higher the priority
CACHE1D_SOURCE_DRIVE = 0,
CACHE1D_SOURCE_CURDIR = 1,
CACHE1D_SOURCE_PATH = 2, // + path stack depth
CACHE1D_SOURCE_ZIP = 0x7ffffffe,
CACHE1D_SOURCE_GRP = 0x7fffffff,
};
typedef struct _CACHE1D_FIND_REC {
char *name;
int type, source;
struct _CACHE1D_FIND_REC *next, *prev, *usera, *userb;
char *name;
int type, source;
struct _CACHE1D_FIND_REC *next, *prev, *usera, *userb;
} CACHE1D_FIND_REC;
void klistfree(CACHE1D_FIND_REC *rec);
CACHE1D_FIND_REC *klistpath(const char *path, const char *mask, int type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment