Mercurial > hg > dmlib
view src/dmresw.c @ 1015:5101766dd95c
Error handling consistency.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 01 Mar 2015 04:46:23 +0200 |
parents | b01d04e44b6f |
children | 9f06f6661cdf |
line wrap: on
line source
/* * DMLib * -- Resource management * Programmed and designed by Matti 'ccr' Hamalainen * (C) Copyright 2011-2015 Tecnic Software productions (TNSP) */ #include "dmresw.h" int dmf_write_str(DMResource *f, void *s, size_t l) { return dmfwrite(s, 1, l, f) == l; } BOOL dmf_write_byte(DMResource *f, const Uint8 val) { return dmfputc(val, f) == val; } #define DM_DEFINE_FUNC(xname, xtype, xmacro) \ BOOL dmf_write_ ## xname (DMResource *f, 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) DM_DEFINE_FUNC(be16, Uint16, BE16) DM_DEFINE_FUNC(be32, Uint32, BE32) DM_DEFINE_FUNC(be64, Uint64, BE64)