# HG changeset patch # User Matti Hamalainen # Date 1349090267 -10800 # Node ID be616098142861337938ab3aa412248abe997bc8 # Parent b908fda1036e8b06dcc4ffff51f14669306a7837 Improve and finish write functions in resource subsystem. diff -r b908fda1036e -r be6160981428 dmres.c --- 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) { diff -r b908fda1036e -r be6160981428 dmresw.c --- 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) diff -r b908fda1036e -r be6160981428 dmresw.h --- 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