Mercurial > hg > dmlib
changeset 72:be6160981428
Improve and finish write functions in resource subsystem.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 01 Oct 2012 14:17:47 +0300 |
parents | b908fda1036e |
children | 295d08376744 |
files | dmres.c dmresw.c dmresw.h |
diffstat | 3 files changed, 24 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/dmres.c Mon Oct 01 13:43:09 2012 +0300 +++ b/dmres.c Mon Oct 01 14:17:47 2012 +0300 @@ -766,12 +766,24 @@ return f->fops->fgetc(f); } +int dmputc(int v, DMResource * f) +{ + f->atime = time(NULL); + return f->fops->fputc(v, f); +} + size_t dmfread(void *ptr, size_t size, size_t nmemb, DMResource * f) { f->atime = time(NULL); return f->fops->fread(ptr, size, nmemb, f); } +size_t dmfwrite(void *ptr, size_t size, size_t nmemb, DMResource * f) +{ + f->atime = time(NULL); + return f->fops->fwrite(ptr, size, nmemb, f); +} + int dmres_ref(DMResource *node) {
--- a/dmresw.c Mon Oct 01 13:43:09 2012 +0300 +++ b/dmresw.c Mon Oct 01 14:17:47 2012 +0300 @@ -14,13 +14,12 @@ } -#define DM_DEFINE_FUNC(xname, xtype, xmacro) \ -BOOL dmf_write_ ## xname (DMResource *f, xtype *v) { \ - xtype result; \ - if (dmfwrite(&result, sizeof( xtype ), 1, f) != 1) \ - return FALSE; \ - *v = DM_ ## xmacro ## _TO_NATIVE (result); \ - return TRUE; \ +#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)
--- a/dmresw.h Mon Oct 01 13:43:09 2012 +0300 +++ b/dmresw.h Mon Oct 01 14:17:47 2012 +0300 @@ -14,14 +14,14 @@ #endif int dmf_write_str(DMResource *, Uint8 *, size_t); -BOOL dmf_write_be16(DMResource *, Uint16 *); -BOOL dmf_write_be32(DMResource *, Uint32 *); -BOOL dmf_write_le16(DMResource *, Uint16 *); -BOOL dmf_write_le32(DMResource *, Uint32 *); +BOOL dmf_write_be16(DMResource *, Uint16); +BOOL dmf_write_be32(DMResource *, Uint32); +BOOL dmf_write_le16(DMResource *, Uint16); +BOOL dmf_write_le32(DMResource *, Uint32); #ifdef DM_HAVE_64BIT -BOOL dmf_write_be64(DMResource *, Uint64 *); -BOOL dmf_write_le64(DMResource *, Uint64 *); +BOOL dmf_write_be64(DMResource *, Uint64); +BOOL dmf_write_le64(DMResource *, Uint64); #endif