Mercurial > hg > dmlib
comparison src/dmres.c @ 1088:9f06f6661cdf
Cleanups for file endianess read/write helper functions.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 02 Mar 2015 20:16:43 +0200 |
parents | a0c187dae495 |
children | e06abfde6c39 |
comparison
equal
deleted
inserted
replaced
1087:a0c187dae495 | 1088:9f06f6661cdf |
---|---|
1251 int tmp = dmfgetc(f); | 1251 int tmp = dmfgetc(f); |
1252 *val = tmp; | 1252 *val = tmp; |
1253 return tmp != EOF; | 1253 return tmp != EOF; |
1254 } | 1254 } |
1255 | 1255 |
1256 #define DM_DEFINE_FUNC(xname, xtype, xmacro) \ | 1256 |
1257 BOOL dmf_read_ ## xname (DMResource *f, xtype *v) { \ | 1257 #define DM_DEFINE_FFUNC(xname, xtype, xmacro) \ |
1258 BOOL dmf_read_ ## xname (DMResource *f, xtype *v) { \ | 1258 BOOL dmf_read_ ## xname (DMResource *f, xtype *v) { \ |
1259 xtype result; \ | 1259 xtype result; \ |
1260 if (dmfread(&result, sizeof( xtype ), 1, f) != 1) \ | 1260 if (dmfread(&result, sizeof( xtype ), 1, f) != 1) \ |
1261 return FALSE; \ | 1261 return FALSE; \ |
1262 *v = DM_ ## xmacro ## _TO_NATIVE (result); \ | 1262 *v = DM_ ## xmacro ## _TO_NATIVE (result); \ |
1263 return TRUE; \ | 1263 return TRUE; \ |
1264 } | 1264 } |
1265 | 1265 |
1266 DM_DEFINE_FUNC(le16, Uint16, LE16) | 1266 #include "dmfiletmpl.h" |
1267 DM_DEFINE_FUNC(le32, Uint32, LE32) | 1267 |
1268 | 1268 #undef DM_DEFINE_FFUNC |
1269 DM_DEFINE_FUNC(be16, Uint16, BE16) | |
1270 DM_DEFINE_FUNC(be32, Uint32, BE32) | |
1271 | |
1272 DM_DEFINE_FUNC(le64, Uint64, LE64) | |
1273 DM_DEFINE_FUNC(be64, Uint64, BE64) |