Mercurial > hg > dmlib
comparison dmresw.c @ 59:c560703e85ed
Add resource writing functions (only work for stdio backend)
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 01 Oct 2012 07:51:08 +0300 |
parents | |
children | be6160981428 |
comparison
equal
deleted
inserted
replaced
58:76a7d469eab9 | 59:c560703e85ed |
---|---|
1 /* | |
2 * DMLib | |
3 * -- Resource management | |
4 * Programmed and designed by Matti 'ccr' Hamalainen | |
5 * (C) Copyright 2011-2012 Tecnic Software productions (TNSP) | |
6 */ | |
7 #include "dmresw.h" | |
8 | |
9 /* Helper resource access routines | |
10 */ | |
11 int dmf_write_str(DMResource *f, Uint8 *s, size_t l) | |
12 { | |
13 return dmfwrite(s, sizeof(Uint8), l, f) == l; | |
14 } | |
15 | |
16 | |
17 #define DM_DEFINE_FUNC(xname, xtype, xmacro) \ | |
18 BOOL dmf_write_ ## xname (DMResource *f, xtype *v) { \ | |
19 xtype result; \ | |
20 if (dmfwrite(&result, sizeof( xtype ), 1, f) != 1) \ | |
21 return FALSE; \ | |
22 *v = DM_ ## xmacro ## _TO_NATIVE (result); \ | |
23 return TRUE; \ | |
24 } | |
25 | |
26 DM_DEFINE_FUNC(le16, Uint16, LE16) | |
27 DM_DEFINE_FUNC(le32, Uint32, LE32) | |
28 | |
29 DM_DEFINE_FUNC(be16, Uint16, BE16) | |
30 DM_DEFINE_FUNC(be32, Uint32, BE32) | |
31 | |
32 #ifdef DM_HAVE_64BIT | |
33 DM_DEFINE_FUNC(le64, Uint64, LE64) | |
34 DM_DEFINE_FUNC(be64, Uint64, BE64) | |
35 #endif |