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