]> pd.if.org Git - pdclib/blobdiff - functions/stdio/_PDCLIB_seek.c
PDCLIB-8: First phase of intergation of new I/O backend system (with minimal
[pdclib] / functions / stdio / _PDCLIB_seek.c
diff --git a/functions/stdio/_PDCLIB_seek.c b/functions/stdio/_PDCLIB_seek.c
new file mode 100644 (file)
index 0000000..5a3f982
--- /dev/null
@@ -0,0 +1,39 @@
+/* int64_t _PDCLIB_seek( FILE *, int64_t, int )\r
+\r
+   This file is part of the Public Domain C Library (PDCLib).\r
+   Permission is granted to use, modify, and / or redistribute at will.\r
+*/\r
+\r
+#include <stdio.h>\r
+#include <stdint.h>\r
+#include <errno.h>\r
+#ifndef REGTEST\r
+\r
+int_fast64_t _PDCLIB_seek( struct _PDCLIB_file_t * stream, _PDCLIB_int64_t offset, \r
+                           int whence )\r
+{\r
+    int_fast64_t newPos;\r
+    if(!stream->ops->seek(stream->handle, offset, whence, &newPos)) {\r
+        return EOF;\r
+    }\r
+\r
+    stream->ungetidx = 0;\r
+    stream->bufidx = 0;\r
+    stream->bufend = 0;\r
+    stream->pos.offset = newPos;\r
+    return newPos;\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    /* Testing covered by ftell.c */\r
+    return TEST_RESULTS;\r
+}\r
+\r
+#endif\r
+\r