summaryrefslogtreecommitdiffstats
path: root/usr/klibc/stdio/ftell.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/klibc/stdio/ftell.c')
-rw-r--r--usr/klibc/stdio/ftell.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/usr/klibc/stdio/ftell.c b/usr/klibc/stdio/ftell.c
new file mode 100644
index 0000000..cb1202d
--- /dev/null
+++ b/usr/klibc/stdio/ftell.c
@@ -0,0 +1,12 @@
+#include "stdioint.h"
+
+off_t ftell(FILE *file)
+{
+ struct _IO_file_pvt *f = stdio_pvt(file);
+ off_t pos = lseek(f->pub._IO_fileno, 0, SEEK_CUR);
+
+ if (pos >= 0)
+ pos += (int)f->obytes - (int)f->ibytes;
+
+ return pos;
+}