Subversion Repositories Kolibri OS

Rev

Rev 4921 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  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. /*
  19. FUNCTION
  20. <<fseek>>, <<fseeko>>---set file position
  21.  
  22. INDEX
  23.         fseek
  24. INDEX
  25.         fseeko
  26. INDEX
  27.         _fseek_r
  28. INDEX
  29.         _fseeko_r
  30.  
  31. ANSI_SYNOPSIS
  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.  
  40. TRAD_SYNOPSIS
  41.         #include <stdio.h>
  42.         int fseek(<[fp]>, <[offset]>, <[whence]>);
  43.         FILE *<[fp]>;
  44.         long <[offset]>;
  45.         int <[whence]>;
  46.  
  47.         int fseeko(<[fp]>, <[offset]>, <[whence]>);
  48.         FILE *<[fp]>;
  49.         off_t <[offset]>;
  50.         int <[whence]>;
  51.  
  52.         int _fseek_r(<[ptr]>, <[fp]>, <[offset]>, <[whence]>);
  53.         struct _reent *<[ptr]>;
  54.         FILE *<[fp]>;
  55.         long <[offset]>;
  56.         int <[whence]>;
  57.  
  58.         int _fseeko_r(<[ptr]>, <[fp]>, <[offset]>, <[whence]>);
  59.         struct _reent *<[ptr]>;
  60.         FILE *<[fp]>;
  61.         off_t <[offset]>;
  62.         int <[whence]>;
  63.  
  64. DESCRIPTION
  65. Objects of type <<FILE>> can have a ``position'' that records how much
  66. of the file your program has already read.  Many of the <<stdio>> functions
  67. depend on this position, and many change it as a side effect.
  68.  
  69. You can use <<fseek>>/<<fseeko>> to set the position for the file identified by
  70. <[fp]>.  The value of <[offset]> determines the new position, in one
  71. of three ways selected by the value of <[whence]> (defined as macros
  72. in `<<stdio.h>>'):
  73.  
  74. <<SEEK_SET>>---<[offset]> is the absolute file position (an offset
  75. from the beginning of the file) desired.  <[offset]> must be positive.
  76.  
  77. <<SEEK_CUR>>---<[offset]> is relative to the current file position.
  78. <[offset]> can meaningfully be either positive or negative.
  79.  
  80. <<SEEK_END>>---<[offset]> is relative to the current end of file.
  81. <[offset]> can meaningfully be either positive (to increase the size
  82. of the file) or negative.
  83.  
  84. See <<ftell>>/<<ftello>> to determine the current file position.
  85.  
  86. RETURNS
  87. <<fseek>>/<<fseeko>> return <<0>> when successful.  On failure, the
  88. result is <<EOF>>.  The reason for failure is indicated in <<errno>>:
  89. either <<ESPIPE>> (the stream identified by <[fp]> doesn't support
  90. repositioning) or <<EINVAL>> (invalid file position).
  91.  
  92. PORTABILITY
  93. ANSI C requires <<fseek>>.
  94.  
  95. <<fseeko>> is defined by the Single Unix specification.
  96.  
  97. Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
  98. <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
  99. */
  100.  
  101. #include <_ansi.h>
  102. #include <reent.h>
  103. #include <stdio.h>
  104. #include <errno.h>
  105. #include "local.h"
  106.  
  107. int
  108. _DEFUN(_fseek_r, (ptr, fp, offset, whence),
  109.        struct _reent *ptr _AND
  110.        register FILE *fp  _AND
  111.        long offset        _AND
  112.        int whence)
  113. {
  114.   return _fseeko_r (ptr, fp, offset, whence);
  115. }
  116.  
  117. #ifndef _REENT_ONLY
  118.  
  119. int
  120. _DEFUN(fseek, (fp, offset, whence),
  121.        register FILE *fp _AND
  122.        long offset       _AND
  123.        int whence)
  124. {
  125.   return _fseek_r (_REENT, fp, offset, whence);
  126. }
  127.  
  128. #endif /* !_REENT_ONLY */
  129.