Path: blob/master/waterbox/libc/functions/stdio/fsetpos.c
2 views
/* fsetpos( FILE *, const fpos_t * )12This file is part of the Public Domain C Library (PDCLib).3Permission is granted to use, modify, and / or redistribute at will.4*/56#include <stdio.h>78#ifndef REGTEST9#include "_PDCLIB_io.h"1011int _PDCLIB_fsetpos_unlocked( FILE * stream,12const _PDCLIB_fpos_t * pos )13{14if ( stream->status & _PDCLIB_FWRITE )15{16if ( _PDCLIB_flushbuffer( stream ) == EOF )17{18return EOF;19}20}21if ( _PDCLIB_seek( stream, pos->offset, SEEK_SET ) == EOF )22{23return EOF;24}25stream->pos.mbs = pos->mbs;2627return 0;28}2930int fsetpos( FILE * stream,31const _PDCLIB_fpos_t * pos )32{33_PDCLIB_flockfile( stream );34int res = _PDCLIB_fsetpos_unlocked( stream, pos );35_PDCLIB_funlockfile( stream );36return res;37}3839#endif4041#ifdef TEST42#include "_PDCLIB_test.h"4344int main( void )45{46/* fsetpos() tested together with fsetpos(). */47return TEST_RESULTS;48}4950#endif515253