]> pd.if.org Git - pdclib/blob - functions/stdio/fsetpos.c
Whitespace cleanups.
[pdclib] / functions / stdio / fsetpos.c
1 /* fsetpos( FILE *, const fpos_t * )
2
3    This file is part of the Public Domain C Library (PDCLib).
4    Permission is granted to use, modify, and / or redistribute at will.
5 */
6
7 #include <stdio.h>
8
9 #ifndef REGTEST
10
11 #include "_PDCLIB_glue.h"
12
13 int fsetpos( struct _PDCLIB_file_t * stream, const struct _PDCLIB_fpos_t * pos )
14 {
15     if ( stream->status & _PDCLIB_FWRITE )
16     {
17         if ( _PDCLIB_flushbuffer( stream ) == EOF )
18         {
19             return EOF;
20         }
21     }
22     if ( _PDCLIB_seek( stream, pos->offset, SEEK_SET ) == EOF )
23     {
24         return EOF;
25     }
26     stream->pos.status = pos->status;
27     /* TODO: Add mbstate. */
28     return 0;
29 }
30
31 #endif
32
33 #ifdef TEST
34
35 #include "_PDCLIB_test.h"
36
37 int main( void )
38 {
39     /* fsetpos() tested together with fsetpos(). */
40     return TEST_RESULTS;
41 }
42
43 #endif