1FSEEK(3) 386BSD Programmer's Manual FSEEK(3) 2 3NNAAMMEE 4 ffggeettppooss, ffsseeeekk, ffsseettppooss, fftteellll, rreewwiinndd - reposition a stream 5 6SSYYNNOOPPSSIISS 7 ##iinncclluuddee <<ssttddiioo..hh>> 8 9 _i_n_t 10 ffsseeeekk(_F_I_L_E *_s_t_r_e_a_m, _l_o_n_g _o_f_f_s_e_t, _i_n_t _w_h_e_n_c_e) 11 12 _l_o_n_g 13 fftteellll(_F_I_L_E *_s_t_r_e_a_m) 14 15 _v_o_i_d 16 rreewwiinndd(_F_I_L_E *_s_t_r_e_a_m) 17 18 _i_n_t 19 ffggeettppooss(_F_I_L_E *_s_t_r_e_a_m, _f_p_o_s__t *_p_o_s) 20 21 _i_n_t 22 ffsseettppooss(_F_I_L_E *_s_t_r_e_a_m, _f_p_o_s__t *_p_o_s) 23 24DDEESSCCRRIIPPTTIIOONN 25 The ffsseeeekk() function sets the file position indicator for the stream 26 pointed to by _s_t_r_e_a_m. The new position, measured in bytes, is obtained by 27 adding _o_f_f_s_e_t bytes to the position specified by _w_h_e_n_c_e. If _w_h_e_n_c_e is set 28 to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to the start 29 of the file, the current position indicator, or end-of-file, 30 respectively. A successful call to the ffsseeeekk() function clears the end- 31 of-file indicator for the stream and undoes any effects of the ungetc(3) 32 function on the same stream. 33 34 The fftteellll() function obtains the current value of the file position 35 indicator for the stream pointed to by _s_t_r_e_a_m. 36 37 The rreewwiinndd() function sets the file position indicator for the stream 38 pointed to by _s_t_r_e_a_m to the beginning of the file. It is equivalent to: 39 40 (void)fseek(stream, 0L, SEEK_SET) 41 42 except that the error indicator for the stream is also cleared (see 43 clearerr(3)). 44 45 The ffggeettppooss() and ffsseettppooss() functions are alternate interfaces equivalent 46 to fftteellll() and ffsseeeekk() (with whence set to SEEK_SET ), setting and 47 storing the current value of the file offset into or from the object 48 referenced by _p_o_s. On some (non-UNIX) systems an ``_f_p_o_s__t'' object may be 49 a complex object and these routines may be the only way to portably 50 reposition a text stream. 51 52RREETTUURRNN VVAALLUUEESS 53 The rreewwiinndd() function returns no value. Upon successful completion, 54 ffggeettppooss(), ffsseeeekk(), ffsseettppooss() return 0, and fftteellll() returns the current 55 offset. Otherwise, -1 is returned and the global variable errno is set 56 to indicate the error. 57 58EERRRROORRSS 59 [EBADF] The _s_t_r_e_a_m specified is not a seekable stream. 60 61 [EINVAL] The _w_h_e_n_c_e argument to ffsseeeekk() was not SEEK_SET, SEEK_END, or 62 SEEK_CUR. 63 64 The function ffggeettppooss(), ffsseeeekk(), ffsseettppooss(), and fftteellll() may also fail and 65 set _e_r_r_n_o for any of the errors specified for the routines fflush(3), 66 fstat(2), lseek(2), and malloc(3). 67 68SSEEEE AALLSSOO 69 lseek(2) 70 71SSTTAANNDDAARRDDSS 72 The ffggeettppooss(), ffsseettppooss(), ffsseeeekk(), fftteellll(), and rreewwiinndd() functions 73 conform to ANSI C3.159-1989 (``ANSI C''). 74 75BSD Experimental June 29, 1991 2 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133