diff src/dmresw.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 b01d04e44b6f
children 0cac3360a0aa
line wrap: on
line diff
--- a/src/dmresw.c	Mon Mar 02 20:10:44 2015 +0200
+++ b/src/dmresw.c	Mon Mar 02 20:16:43 2015 +0200
@@ -6,7 +6,8 @@
  */
 #include "dmresw.h"
 
-int dmf_write_str(DMResource *f, void *s, size_t l)
+
+int dmf_write_str(DMResource *f, const void *s, const size_t l)
 {
     return dmfwrite(s, 1, l, f) == l;
 }
@@ -18,18 +19,14 @@
 }
 
 
-#define DM_DEFINE_FUNC(xname, xtype, xmacro)            \
-BOOL dmf_write_ ## xname (DMResource *f, xtype v) {     \
+#define DM_DEFINE_FFUNC(xname, xtype, xmacro)            \
+BOOL dmf_write_ ## xname (DMResource *f, const xtype v) {     \
     xtype result = DM_NATIVE_TO_ ## xmacro (v);         \
     if (dmfwrite(&result, sizeof( xtype ), 1, f) != 1)  \
         return FALSE;                                   \
     return TRUE;                                        \
 }
 
-DM_DEFINE_FUNC(le16, Uint16, LE16)
-DM_DEFINE_FUNC(le32, Uint32, LE32)
-DM_DEFINE_FUNC(le64, Uint64, LE64)
+#include "dmfiletmpl.h"
 
-DM_DEFINE_FUNC(be16, Uint16, BE16)
-DM_DEFINE_FUNC(be32, Uint32, BE32)
-DM_DEFINE_FUNC(be64, Uint64, BE64)
+#undef DM_DEFINE_FFUNC