Show control key combos with uppercase alpha
[aNetHack.git] / include / dlb.h
blob5fca33acbf9005387e8bbb3530e4e9174f1e109a
1 /* NetHack 3.6 dlb.h $NHDT-Date: 1432512780 2015/05/25 00:13:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
2 /* Copyright (c) Kenneth Lorber, Bethesda, Maryland, 1993. */
3 /* NetHack may be freely redistributed. See license for details. */
5 #ifndef DLB_H
6 #define DLB_H
7 /* definitions for data library */
9 #ifdef DLB
11 /* implementations */
12 #ifdef MAC
13 #define DLBRSRC /* use Mac resources */
14 #else
15 #define DLBLIB /* use a set of external files */
16 #endif
18 #ifdef DLBLIB
19 /* directory structure in memory */
20 typedef struct dlb_directory {
21 char *fname; /* file name as seen from calling code */
22 long foffset; /* offset in lib file to start of this file */
23 long fsize; /* file size */
24 char handling; /* how to handle the file (compression, etc) */
25 } libdir;
27 /* information about each open library */
28 typedef struct dlb_library {
29 FILE *fdata; /* opened data file */
30 long fmark; /* current file mark */
31 libdir *dir; /* directory of library file */
32 char *sspace; /* pointer to string space */
33 long nentries; /* # of files in directory */
34 long rev; /* dlb file revision */
35 long strsize; /* dlb file string size */
36 } library;
38 /* library definitions */
39 #ifndef DLBFILE
40 #define DLBFILE "nhdat" /* name of library */
41 #endif
42 #ifndef FILENAME_CMP
43 #define FILENAME_CMP strcmp /* case sensitive */
44 #endif
46 #endif /* DLBLIB */
48 typedef struct dlb_handle {
49 FILE *fp; /* pointer to an external file, use if non-null */
50 #ifdef DLBLIB
51 library *lib; /* pointer to library structure */
52 long start; /* offset of start of file */
53 long size; /* size of file */
54 long mark; /* current file marker */
55 #endif
56 #ifdef DLBRSRC
57 int fd; /* HandleFile file descriptor */
58 #endif
59 } dlb;
61 #if defined(ULTRIX_PROTO) && !defined(__STDC__)
62 /* buggy old Ultrix compiler wants this for the (*dlb_fread_proc)
63 and (*dlb_fgets_proc) prototypes in struct dlb_procs (dlb.c);
64 we'll use it in all the declarations for consistency */
65 #define DLB_P struct dlb_handle *
66 #else
67 #define DLB_P dlb *
68 #endif
70 boolean NDECL(dlb_init);
71 void NDECL(dlb_cleanup);
73 dlb *FDECL(dlb_fopen, (const char *, const char *));
74 int FDECL(dlb_fclose, (DLB_P));
75 int FDECL(dlb_fread, (char *, int, int, DLB_P));
76 int FDECL(dlb_fseek, (DLB_P, long, int));
77 char *FDECL(dlb_fgets, (char *, int, DLB_P));
78 int FDECL(dlb_fgetc, (DLB_P));
79 long FDECL(dlb_ftell, (DLB_P));
81 /* Resource DLB entry points */
82 #ifdef DLBRSRC
83 boolean rsrc_dlb_init(void);
84 void rsrc_dlb_cleanup(void);
85 boolean rsrc_dlb_fopen(dlb *dp, const char *name, const char *mode);
86 int rsrc_dlb_fclose(dlb *dp);
87 int rsrc_dlb_fread(char *buf, int size, int quan, dlb *dp);
88 int rsrc_dlb_fseek(dlb *dp, long pos, int whence);
89 char *rsrc_dlb_fgets(char *buf, int len, dlb *dp);
90 int rsrc_dlb_fgetc(dlb *dp);
91 long rsrc_dlb_ftell(dlb *dp);
92 #endif
94 #else /* DLB */
96 #define dlb FILE
98 #define dlb_init()
99 #define dlb_cleanup()
101 #define dlb_fopen fopen
102 #define dlb_fclose fclose
103 #define dlb_fread fread
104 #define dlb_fseek fseek
105 #define dlb_fgets fgets
106 #define dlb_fgetc fgetc
107 #define dlb_ftell ftell
109 #endif /* DLB */
111 /* various other I/O stuff we don't want to replicate everywhere */
113 #ifndef SEEK_SET
114 #define SEEK_SET 0
115 #endif
116 #ifndef SEEK_CUR
117 #define SEEK_CUR 1
118 #endif
119 #ifndef SEEK_END
120 #define SEEK_END 2
121 #endif
123 #define RDTMODE "r"
124 #if (defined(MSDOS) || defined(WIN32) || defined(TOS) || defined(OS2)) \
125 && defined(DLB)
126 #define WRTMODE "w+b"
127 #else
128 #define WRTMODE "w+"
129 #endif
130 #if (defined(MICRO) && !defined(AMIGA)) || defined(THINK_C) \
131 || defined(__MWERKS__) || defined(WIN32)
132 #define RDBMODE "rb"
133 #define WRBMODE "w+b"
134 #else
135 #define RDBMODE "r"
136 #define WRBMODE "w+"
137 #endif
139 #endif /* DLB_H */