3 /* fgetpos( FILE * , fpos_t * )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
13 int fgetpos_unlocked( struct _PDCLIB_file_t * _PDCLIB_restrict stream, struct _PDCLIB_fpos_t * _PDCLIB_restrict pos )
15 pos->offset = stream->pos.offset + stream->bufidx - stream->ungetidx;
16 pos->status = stream->pos.status;
17 /* TODO: Add mbstate. */
21 int fgetpos( struct _PDCLIB_file_t * _PDCLIB_restrict stream, struct _PDCLIB_fpos_t * _PDCLIB_restrict pos )
24 int res = fgetpos_unlocked( stream, pos );
25 funlockfile( stream );
32 #include <_PDCLIB_test.h>
39 TESTCASE( ( fh = tmpfile() ) != NULL );
40 TESTCASE( fgetpos( fh, &pos1 ) == 0 );
41 TESTCASE( fwrite( teststring, 1, strlen( teststring ), fh ) == strlen( teststring ) );
42 TESTCASE( (size_t)ftell( fh ) == strlen( teststring ) );
43 TESTCASE( fgetpos( fh, &pos2 ) == 0 );
44 TESTCASE( fsetpos( fh, &pos1 ) == 0 );
45 TESTCASE( ftell( fh ) == 0 );
46 TESTCASE( fsetpos( fh, &pos2 ) == 0 );
47 TESTCASE( (size_t)ftell( fh ) == strlen( teststring ) );
48 TESTCASE( fclose( fh ) == 0 );