source: trunk/libs/newlib/src/newlib/libc/stdio/fseek.c @ 543

Last change on this file since 543 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 3.1 KB
Line 
1/*
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley.  The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16 */
17
18/*
19FUNCTION
20<<fseek>>, <<fseeko>>---set file position
21
22INDEX
23        fseek
24INDEX
25        fseeko
26INDEX
27        _fseek_r
28INDEX
29        _fseeko_r
30
31SYNOPSIS
32        #include <stdio.h>
33        int fseek(FILE *<[fp]>, long <[offset]>, int <[whence]>);
34        int fseeko(FILE *<[fp]>, off_t <[offset]>, int <[whence]>);
35        int _fseek_r(struct _reent *<[ptr]>, FILE *<[fp]>,
36                     long <[offset]>, int <[whence]>);
37        int _fseeko_r(struct _reent *<[ptr]>, FILE *<[fp]>,
38                     off_t <[offset]>, int <[whence]>);
39
40DESCRIPTION
41Objects of type <<FILE>> can have a ``position'' that records how much
42of the file your program has already read.  Many of the <<stdio>> functions
43depend on this position, and many change it as a side effect.
44
45You can use <<fseek>>/<<fseeko>> to set the position for the file identified by
46<[fp]>.  The value of <[offset]> determines the new position, in one
47of three ways selected by the value of <[whence]> (defined as macros
48in `<<stdio.h>>'):
49
50<<SEEK_SET>>---<[offset]> is the absolute file position (an offset
51from the beginning of the file) desired.  <[offset]> must be positive.
52
53<<SEEK_CUR>>---<[offset]> is relative to the current file position.
54<[offset]> can meaningfully be either positive or negative.
55
56<<SEEK_END>>---<[offset]> is relative to the current end of file.
57<[offset]> can meaningfully be either positive (to increase the size
58of the file) or negative.
59
60See <<ftell>>/<<ftello>> to determine the current file position.
61
62RETURNS
63<<fseek>>/<<fseeko>> return <<0>> when successful.  On failure, the
64result is <<EOF>>.  The reason for failure is indicated in <<errno>>:
65either <<ESPIPE>> (the stream identified by <[fp]> doesn't support
66repositioning) or <<EINVAL>> (invalid file position).
67
68PORTABILITY
69ANSI C requires <<fseek>>.
70
71<<fseeko>> is defined by the Single Unix specification.
72
73Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
74<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
75*/
76
77#include <_ansi.h>
78#include <reent.h>
79#include <stdio.h>
80#include <errno.h>
81#include "local.h"
82
83int
84_fseek_r (struct _reent *ptr,
85       register FILE *fp,
86       long offset,
87       int whence)
88{
89  return _fseeko_r (ptr, fp, offset, whence);
90}
91
92#ifndef _REENT_ONLY
93
94int
95fseek (register FILE *fp,
96       long offset,
97       int whence)
98{
99  return _fseek_r (_REENT, fp, offset, whence);
100}
101
102#endif /* !_REENT_ONLY */
Note: See TracBrowser for help on using the repository browser.