diff dmres.c @ 59:c560703e85ed

Add resource writing functions (only work for stdio backend)
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 01 Oct 2012 07:51:08 +0300
parents b2fe4301384d
children be6160981428
line wrap: on
line diff
--- a/dmres.c	Mon Oct 01 07:09:37 2012 +0300
+++ b/dmres.c	Mon Oct 01 07:51:08 2012 +0300
@@ -228,6 +228,14 @@
 }
 
 
+static int dm_stdio_fputc(int v, DMResource * f)
+{
+    int ret = fputc(v, f->fh);
+    f->error = dmGetErrno();
+    return ret;
+}
+
+
 static size_t dm_stdio_fread(void *ptr, size_t size, size_t nmemb, DMResource * f)
 {
     size_t ret = fread(ptr, size, nmemb, f->fh);
@@ -236,6 +244,14 @@
 }
 
 
+static size_t dm_stdio_fwrite(void *ptr, size_t size, size_t nmemb, DMResource * f)
+{
+    size_t ret = fwrite(ptr, size, nmemb, f->fh);
+    f->error = dmGetErrno();
+    return ret;
+}
+
+
 static int dm_stdio_preload(DMResource *handle)
 {
     int ret = dm_stdio_fopen(handle);
@@ -263,7 +279,9 @@
     dm_stdio_ftell,
     dm_stdio_feof,
     dm_stdio_fgetc,
+    dm_stdio_fputc,
     dm_stdio_fread,
+    dm_stdio_fwrite,
 
     dm_stdio_fopen,
     dm_stdio_fclose,
@@ -278,7 +296,9 @@
     dm_stdio_ftell,
     dm_stdio_feof,
     dm_stdio_fgetc,
+    dm_stdio_fputc,
     dm_stdio_fread,
+    dm_stdio_fwrite,
 
     NULL,
     NULL,
@@ -484,7 +504,9 @@
     dm_mem_ftell,
     dm_mem_feof,
     dm_mem_fgetc,
+    NULL,
     dm_mem_fread,
+    NULL,
     
     NULL,
     dm_mem_fclose,
@@ -500,7 +522,9 @@
     dm_mem_ftell,
     dm_mem_feof,
     dm_mem_fgetc,
+    NULL,
     dm_mem_fread,
+    NULL,
     
     NULL,
     NULL,