Mercurial > hg > dmlib
comparison src/dmres.h @ 2586:9807ae37ad69
Require stdbool.h, we require C11 now.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 08 Dec 2022 15:59:22 +0200 |
parents | 8193f62a541d |
children |
comparison
equal
deleted
inserted
replaced
2585:ef6c826c5b7a | 2586:9807ae37ad69 |
---|---|
80 } DMResource; | 80 } DMResource; |
81 | 81 |
82 | 82 |
83 typedef struct DMResourceDataOps | 83 typedef struct DMResourceDataOps |
84 { | 84 { |
85 BOOL (*probe)(DMResource *res, const char *fext); | 85 bool (*probe)(DMResource *res, const char *fext); |
86 int (*load)(DMResource *res); | 86 int (*load)(DMResource *res); |
87 void (*free)(DMResource *res); | 87 void (*free)(DMResource *res); |
88 } DMResourceDataOps; | 88 } DMResourceDataOps; |
89 | 89 |
90 | 90 |
114 int (*freset)(DMResource *); | 114 int (*freset)(DMResource *); |
115 int (*ferror)(DMResource *); | 115 int (*ferror)(DMResource *); |
116 int (*fseek)(DMResource *, const off_t, const int); | 116 int (*fseek)(DMResource *, const off_t, const int); |
117 off_t (*fsize)(DMResource *); | 117 off_t (*fsize)(DMResource *); |
118 off_t (*ftell)(DMResource *); | 118 off_t (*ftell)(DMResource *); |
119 BOOL (*feof)(DMResource *); | 119 bool (*feof)(DMResource *); |
120 int (*fgetc)(DMResource *); | 120 int (*fgetc)(DMResource *); |
121 int (*fputc)(int, DMResource *); | 121 int (*fputc)(int, DMResource *); |
122 size_t (*fread)(void *, const size_t, const size_t, DMResource *); | 122 size_t (*fread)(void *, const size_t, const size_t, DMResource *); |
123 size_t (*fwrite)(const void *, const size_t, const size_t, DMResource *); | 123 size_t (*fwrite)(const void *, const size_t, const size_t, DMResource *); |
124 | 124 |
128 /* Functions | 128 /* Functions |
129 */ | 129 */ |
130 int dmResourcesInit(DMResourceLib **lib, const char *filename, const char *path, const int flags, int (*classifier)(DMResource *)); | 130 int dmResourcesInit(DMResourceLib **lib, const char *filename, const char *path, const int flags, int (*classifier)(DMResource *)); |
131 int dmResourcesClose(DMResourceLib *lib); | 131 int dmResourcesClose(DMResourceLib *lib); |
132 | 132 |
133 int dmResourcesPreload(DMResourceLib *lib, BOOL start, int *loaded, int *total); | 133 int dmResourcesPreload(DMResourceLib *lib, bool start, int *loaded, int *total); |
134 | 134 |
135 DMResource * dmResourceNew(DMResourceLib *lib, const char *filename, const size_t size, const int flags); | 135 DMResource * dmResourceNew(DMResourceLib *lib, const char *filename, const size_t size, const int flags); |
136 void dmResourceFree(DMResource *node); | 136 void dmResourceFree(DMResource *node); |
137 void dmResourceInsert(DMResourceLib *lib, DMResource * node); | 137 void dmResourceInsert(DMResourceLib *lib, DMResource * node); |
138 void dmResourceDelete(DMResourceLib *lib, DMResource * node); | 138 void dmResourceDelete(DMResourceLib *lib, DMResource * node); |
157 int dmfreset(DMResource *fh); | 157 int dmfreset(DMResource *fh); |
158 int dmferror(DMResource *fh); | 158 int dmferror(DMResource *fh); |
159 int dmfseek(DMResource *fh, const off_t offset, const int whence); | 159 int dmfseek(DMResource *fh, const off_t offset, const int whence); |
160 off_t dmfsize(DMResource *fh); | 160 off_t dmfsize(DMResource *fh); |
161 off_t dmftell(DMResource *fh); | 161 off_t dmftell(DMResource *fh); |
162 BOOL dmfeof(DMResource *fh); | 162 bool dmfeof(DMResource *fh); |
163 int dmfgetc(DMResource *fh); | 163 int dmfgetc(DMResource *fh); |
164 int dmfputc(int val, DMResource *fh); | 164 int dmfputc(int val, DMResource *fh); |
165 size_t dmfread(void *ptr, const size_t size, const size_t nmemb, DMResource *fh); | 165 size_t dmfread(void *ptr, const size_t size, const size_t nmemb, DMResource *fh); |
166 size_t dmfwrite(const void *ptr, const size_t size, const size_t nmemb, DMResource *fh); | 166 size_t dmfwrite(const void *ptr, const size_t size, const size_t nmemb, DMResource *fh); |
167 char * dmfgets(char *str, const int size, DMResource *fh); | 167 char * dmfgets(char *str, const int size, DMResource *fh); |
169 int dmvfprintf(DMResource *fh, const char *fmt, va_list ap); | 169 int dmvfprintf(DMResource *fh, const char *fmt, va_list ap); |
170 int dmfprintf(DMResource *fh, const char *fmt, ...) | 170 int dmfprintf(DMResource *fh, const char *fmt, ...) |
171 DM_ATTR_PRINTF_FMT(2, 3); | 171 DM_ATTR_PRINTF_FMT(2, 3); |
172 | 172 |
173 // Helper functions for endianess based reading etc | 173 // Helper functions for endianess based reading etc |
174 BOOL dmf_read_str(DMResource *fh, void *ptr, const size_t len); | 174 bool dmf_read_str(DMResource *fh, void *ptr, const size_t len); |
175 BOOL dmf_read_byte(DMResource *fh, Uint8 *val); | 175 bool dmf_read_byte(DMResource *fh, Uint8 *val); |
176 | 176 |
177 #define DM_DEFINE_FFUNC(xname, xtype, z) \ | 177 #define DM_DEFINE_FFUNC(xname, xtype, z) \ |
178 BOOL dmf_read_ ## xname (DMResource *fh, xtype *v); | 178 bool dmf_read_ ## xname (DMResource *fh, xtype *v); |
179 | 179 |
180 #include "dmfiletmpl.h" | 180 #include "dmfiletmpl.h" |
181 | 181 |
182 #undef DM_DEFINE_FFUNC | 182 #undef DM_DEFINE_FFUNC |
183 | 183 |
184 BOOL dmf_write_str(DMResource *fh, const void *data, const size_t len); | 184 bool dmf_write_str(DMResource *fh, const void *data, const size_t len); |
185 BOOL dmf_write_byte(DMResource *fh, const Uint8 val); | 185 bool dmf_write_byte(DMResource *fh, const Uint8 val); |
186 | 186 |
187 #define DM_DEFINE_FFUNC(xname, xtype, z) \ | 187 #define DM_DEFINE_FFUNC(xname, xtype, z) \ |
188 BOOL dmf_write_ ## xname (DMResource *fh, const xtype v); | 188 bool dmf_write_ ## xname (DMResource *fh, const xtype v); |
189 | 189 |
190 #include "dmfiletmpl.h" | 190 #include "dmfiletmpl.h" |
191 | 191 |
192 #undef DM_DEFINE_FFUNC | 192 #undef DM_DEFINE_FFUNC |
193 | 193 |