about summary refs log tree commit diff
path: root/src/internal/shgetc.h
blob: 3434cdaa132e197c36753c9efea8907066345e5f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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--;
}