MCPcopy Create free account
hub / github.com/GJDuck/e9patch / ftell

Function ftell

examples/stdlib.c:3776–3792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3774}
3775
3776static long ftell(FILE *stream)
3777{
3778 long result = -1, offset = 0;
3779 stdio_lock(stream, -1);
3780 if (stream->flags & STDIO_FLAG_READING)
3781 {
3782 offset = -(stream->read_end - stream->read_ptr);
3783 offset -= (stream->unget != EOF? 1: 0);
3784 }
3785 else if (stream->flags & STDIO_FLAG_WRITING)
3786 offset = stream->write_ptr - stream->buf;
3787 result = lseek(stream->fd, 0, SEEK_CUR);
3788 if (result >= 0)
3789 result += offset;
3790 stdio_unlock(stream);
3791 return result;
3792}
3793
3794/****************************************************************************/
3795/* PRINTF */

Callers 1

test_stdioFunction · 0.85

Calls 1

lseekFunction · 0.85

Tested by 1

test_stdioFunction · 0.68