Mercurial > hg > dmlib
annotate src/dmresw.c @ 2070:41df24d1dfb6
Cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 05 Dec 2018 14:41:25 +0200 |
parents | 73545a442ffe |
children | 9807ae37ad69 |
rev | line source |
---|---|
59
c560703e85ed
Add resource writing functions (only work for stdio backend)
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
c560703e85ed
Add resource writing functions (only work for stdio backend)
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * DMLib |
c560703e85ed
Add resource writing functions (only work for stdio backend)
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * -- Resource management |
c560703e85ed
Add resource writing functions (only work for stdio backend)
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 * Programmed and designed by Matti 'ccr' Hamalainen |
863 | 5 * (C) Copyright 2011-2015 Tecnic Software productions (TNSP) |
59
c560703e85ed
Add resource writing functions (only work for stdio backend)
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 */ |
1881
73545a442ffe
Move dmresw function declarations to dmres.h
Matti Hamalainen <ccr@tnsp.org>
parents:
1607
diff
changeset
|
7 #include "dmres.h" |
59
c560703e85ed
Add resource writing functions (only work for stdio backend)
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 |
1088
9f06f6661cdf
Cleanups for file endianess read/write helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
872
diff
changeset
|
9 |
1607 | 10 BOOL dmf_write_str(DMResource *fh, const void *data, const size_t len) |
59
c560703e85ed
Add resource writing functions (only work for stdio backend)
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 { |
1607 | 12 return dmfwrite(data, len, 1, fh) == 1; |
59
c560703e85ed
Add resource writing functions (only work for stdio backend)
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 } |
c560703e85ed
Add resource writing functions (only work for stdio backend)
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 |
c560703e85ed
Add resource writing functions (only work for stdio backend)
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 |
1607 | 16 BOOL dmf_write_byte(DMResource *fh, const Uint8 val) |
437
3d9c044ec08d
Add dmf_{write,read}_byte() convenience functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
17 { |
1607 | 18 return dmfputc(val, fh) == val; |
437
3d9c044ec08d
Add dmf_{write,read}_byte() convenience functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
19 } |
3d9c044ec08d
Add dmf_{write,read}_byte() convenience functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
20 |
3d9c044ec08d
Add dmf_{write,read}_byte() convenience functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
21 |
1088
9f06f6661cdf
Cleanups for file endianess read/write helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
872
diff
changeset
|
22 #define DM_DEFINE_FFUNC(xname, xtype, xmacro) \ |
9f06f6661cdf
Cleanups for file endianess read/write helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
872
diff
changeset
|
23 BOOL dmf_write_ ## xname (DMResource *f, const xtype v) { \ |
72
be6160981428
Improve and finish write functions in resource subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
24 xtype result = DM_NATIVE_TO_ ## xmacro (v); \ |
be6160981428
Improve and finish write functions in resource subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
25 if (dmfwrite(&result, sizeof( xtype ), 1, f) != 1) \ |
be6160981428
Improve and finish write functions in resource subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
26 return FALSE; \ |
be6160981428
Improve and finish write functions in resource subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
27 return TRUE; \ |
59
c560703e85ed
Add resource writing functions (only work for stdio backend)
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 } |
c560703e85ed
Add resource writing functions (only work for stdio backend)
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 |
1088
9f06f6661cdf
Cleanups for file endianess read/write helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
872
diff
changeset
|
30 #include "dmfiletmpl.h" |
59
c560703e85ed
Add resource writing functions (only work for stdio backend)
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 |
1088
9f06f6661cdf
Cleanups for file endianess read/write helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
872
diff
changeset
|
32 #undef DM_DEFINE_FFUNC |