Subversion Repositories eduke32

Rev

Rev 5059 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5059 Rev 5061
1
// cache1d.h
1
// cache1d.h
2
2
3
#ifndef cache1d_h_
3
#ifndef cache1d_h_
4
#define cache1d_h_
4
#define cache1d_h_
5
5
6
#include "compat.h"
6
#include "compat.h"
7
#include "mutex.h"
7
#include "mutex.h"
8
8
9
#ifdef __cplusplus
9
#ifdef __cplusplus
10
extern "C" {
10
extern "C" {
11
#endif
11
#endif
12
12
13
#ifdef WITHKPLIB
13
#ifdef WITHKPLIB
14
int32_t cache1d_file_fromzip(int32_t fil);
14
int32_t cache1d_file_fromzip(int32_t fil);
15
extern char *kpzbuf;
15
extern char *kpzbuf;
16
extern int32_t kpzbufsiz;
16
extern int32_t kpzbufsiz;
17
#endif
17
#endif
18
18
19
void    initcache(intptr_t dacachestart, int32_t dacachesize);
19
void    initcache(intptr_t dacachestart, int32_t dacachesize);
20
void    allocache(intptr_t *newhandle, int32_t newbytes, char *newlockptr);
20
void    allocache(intptr_t *newhandle, int32_t newbytes, char *newlockptr);
21
void    agecache(void);
21
void    agecache(void);
22
22
23
extern int32_t pathsearchmode;  // 0 = gamefs mode (default), 1 = localfs mode (editor's mode)
23
extern int32_t pathsearchmode;  // 0 = gamefs mode (default), 1 = localfs mode (editor's mode)
24
char *listsearchpath(int32_t initp);
24
char *listsearchpath(int32_t initp);
25
#define addsearchpath(a) addsearchpath_user(a, 0)
25
#define addsearchpath(a) addsearchpath_user(a, 0)
26
int32_t     addsearchpath_user(const char *p, int32_t user);
26
int32_t     addsearchpath_user(const char *p, int32_t user);
27
int32_t     removesearchpath(const char *p);
27
int32_t     removesearchpath(const char *p);
28
void     removesearchpaths_withuser(int32_t usermask);
28
void     removesearchpaths_withuser(int32_t usermask);
29
int32_t         findfrompath(const char *fn, char **where);
29
int32_t         findfrompath(const char *fn, char **where);
30
int32_t     openfrompath(const char *fn, int32_t flags, int32_t mode);
30
int32_t     openfrompath(const char *fn, int32_t flags, int32_t mode);
31
BFILE  *fopenfrompath(const char *fn, const char *mode);
31
BFILE  *fopenfrompath(const char *fn, const char *mode);
32
32
33
int32_t initgroupfile(const char *filename);
33
int32_t initgroupfile(const char *filename);
34
void    uninitgroupfile(void);
34
void    uninitgroupfile(void);
35
int32_t kopen4load(const char *filename, char searchfirst);     // searchfirst: 0 = anywhere, 1 = first group, 2 = any group
35
int32_t kopen4load(const char *filename, char searchfirst);     // searchfirst: 0 = anywhere, 1 = first group, 2 = any group
36
int32_t kread(int32_t handle, void *buffer, int32_t leng);
36
int32_t kread(int32_t handle, void *buffer, int32_t leng);
37
int32_t klseek(int32_t handle, int32_t offset, int32_t whence);
37
int32_t klseek(int32_t handle, int32_t offset, int32_t whence);
38
int32_t kfilelength(int32_t handle);
38
int32_t kfilelength(int32_t handle);
39
int32_t ktell(int32_t handle);
39
int32_t ktell(int32_t handle);
40
void    kclose(int32_t handle);
40
void    kclose(int32_t handle);
41
41
-
 
42
void krename(const char *filename, const char *newname);
-
 
43
42
typedef struct { intptr_t *hand; int32_t leng; char *lock ; } cactype;
44
typedef struct { intptr_t *hand; int32_t leng; char *lock ; } cactype;
43
45
44
enum {
46
enum {
45
        CACHE1D_FIND_FILE = 1,
47
        CACHE1D_FIND_FILE = 1,
46
        CACHE1D_FIND_DIR = 2,
48
        CACHE1D_FIND_DIR = 2,
47
        CACHE1D_FIND_DRIVE = 4,
49
        CACHE1D_FIND_DRIVE = 4,
48
        CACHE1D_FIND_NOCURDIR = 8,
50
        CACHE1D_FIND_NOCURDIR = 8,
49
51
50
        CACHE1D_OPT_NOSTACK = 0x100,
52
        CACHE1D_OPT_NOSTACK = 0x100,
51
       
53
       
52
        // the lower the number, the higher the priority
54
        // the lower the number, the higher the priority
53
        CACHE1D_SOURCE_DRIVE = 0,
55
        CACHE1D_SOURCE_DRIVE = 0,
54
        CACHE1D_SOURCE_CURDIR = 1,
56
        CACHE1D_SOURCE_CURDIR = 1,
55
        CACHE1D_SOURCE_PATH = 2,        // + path stack depth
57
        CACHE1D_SOURCE_PATH = 2,        // + path stack depth
56
        CACHE1D_SOURCE_ZIP = 0x7ffffffe,
58
        CACHE1D_SOURCE_ZIP = 0x7ffffffe,
57
        CACHE1D_SOURCE_GRP = 0x7fffffff,
59
        CACHE1D_SOURCE_GRP = 0x7fffffff,
58
};
60
};
59
typedef struct _CACHE1D_FIND_REC {
61
typedef struct _CACHE1D_FIND_REC {
60
        char *name;
62
        char *name;
61
        int32_t type, source;
63
        int32_t type, source;
62
        struct _CACHE1D_FIND_REC *next, *prev, *usera, *userb;
64
        struct _CACHE1D_FIND_REC *next, *prev, *usera, *userb;
63
} CACHE1D_FIND_REC;
65
} CACHE1D_FIND_REC;
64
void klistfree(CACHE1D_FIND_REC *rec);
66
void klistfree(CACHE1D_FIND_REC *rec);
65
CACHE1D_FIND_REC *klistpath(const char *path, const char *mask, int32_t type);
67
CACHE1D_FIND_REC *klistpath(const char *path, const char *mask, int32_t type);
66
68
67
int32_t kdfread(void *buffer, bsize_t dasizeof, bsize_t count, int32_t fil);
69
int32_t kdfread(void *buffer, bsize_t dasizeof, bsize_t count, int32_t fil);
68
#if 0
70
#if 0
69
int32_t dfread(void *buffer, bsize_t dasizeof, bsize_t count, BFILE *fil);
71
int32_t dfread(void *buffer, bsize_t dasizeof, bsize_t count, BFILE *fil);
70
void    kdfwrite(const void *buffer, bsize_t dasizeof, bsize_t count, int32_t fil);
72
void    kdfwrite(const void *buffer, bsize_t dasizeof, bsize_t count, int32_t fil);
71
#endif
73
#endif
72
void    dfwrite(const void *buffer, bsize_t dasizeof, bsize_t count, BFILE *fil);
74
void    dfwrite(const void *buffer, bsize_t dasizeof, bsize_t count, BFILE *fil);
73
75
74
#ifdef __cplusplus
76
#ifdef __cplusplus
75
}
77
}
76
#endif
78
#endif
77
79
78
#endif // cache1d_h_
80
#endif // cache1d_h_
79
81
80
 
82