about summary refs log tree commit diff
path: root/src/internal/shgetc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal/shgetc.h')
-rw-r--r--src/internal/shgetc.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/internal/shgetc.h b/src/internal/shgetc.h
new file mode 100644
index 00000000..3434cdaa
--- /dev/null
+++ b/src/internal/shgetc.h
@@ -0,0 +1,25 @@
+#include "stdio_impl.h"
+
+void __shlim(FILE *, off_t);
+int __shgetc(FILE *);
+
+static inline off_t shcnt(FILE *f)
+{
+	return f->shcnt + (f->rpos - f->rend);
+}
+
+static inline void shlim(FILE *f, off_t lim)
+{
+	__shlim(f, lim);
+}
+
+static inline int shgetc(FILE *f)
+{
+	if (f->rpos < f->shend) return *f->rpos++;
+	return __shgetc(f);
+}
+
+static inline void shunget(FILE *f)
+{
+	if (f->rend) f->rpos--;
+}