aboutsummaryrefslogtreecommitdiffstats
path: root/src/gfile/inc_stdio.c
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-08-12 16:45:06 +1000
committerinmarket <andrewh@inmarket.com.au>2014-08-12 16:45:06 +1000
commit5460a923ab25d27e522fe175563633665c477e02 (patch)
treee43734965f66092d3d076a599b3b8a188b005bc0 /src/gfile/inc_stdio.c
parent0e74c164c3eac14f6e99d1a5cc4e0563faeff5d0 (diff)
parent10902154aec652a3fcdf028b2c6ff16743464973 (diff)
downloaduGFX-5460a923ab25d27e522fe175563633665c477e02.tar.gz
uGFX-5460a923ab25d27e522fe175563633665c477e02.tar.bz2
uGFX-5460a923ab25d27e522fe175563633665c477e02.zip
Merge branch 'master' into newmouse
Diffstat (limited to 'src/gfile/inc_stdio.c')
-rw-r--r--src/gfile/inc_stdio.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/gfile/inc_stdio.c b/src/gfile/inc_stdio.c
new file mode 100644
index 00000000..8dc44dcb
--- /dev/null
+++ b/src/gfile/inc_stdio.c
@@ -0,0 +1,45 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+/**
+ * This file is included by src/gfile/gfile.c
+ */
+
+/********************************************************
+ * Stdio Emulation Routines
+ ********************************************************/
+
+size_t gstdioRead(void * ptr, size_t size, size_t count, FILE *f) {
+ return gfileRead(f, ptr, size*count)/size;
+}
+
+size_t gstdioWrite(const void * ptr, size_t size, size_t count, FILE *f) {
+ return gfileWrite(f, ptr, size*count)/size;
+}
+
+int gstdioSeek(FILE *f, size_t offset, int origin) {
+ switch(origin) {
+ case SEEK_SET:
+ break;
+ case SEEK_CUR:
+ offset += f->pos;
+ break;
+ case SEEK_END:
+ offset += gfileGetSize(f);
+ break;
+ default:
+ return -1;
+ }
+ return gfileSetPos(f, offset) ? 0 : -1;
+}
+
+int gstdioGetpos(FILE *f, long int *pos) {
+ if (!(f->flags & GFILEFLG_OPEN))
+ return -1;
+ *pos = f->pos;
+ return 0;
+}