FSEEK(3) BSD Programmer's Manual FSEEK(3) NNAAMMEE ffggeettppooss, ffsseeeekk, ffsseettppooss, fftteellll, rreewwiinndd - reposition a stream SSYYNNOOPPSSIISS ##iinncclluuddee <<ssttddiioo..hh>> _i_n_t 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); _l_o_n_g fftteellll(_F_I_L_E _*_s_t_r_e_a_m); _v_o_i_d rreewwiinndd(_F_I_L_E _*_s_t_r_e_a_m); _i_n_t ffggeettppooss(_F_I_L_E _*_s_t_r_e_a_m, _f_p_o_s___t _*_p_o_s); _i_n_t ffsseettppooss(_F_I_L_E _*_s_t_r_e_a_m, _f_p_o_s___t _*_p_o_s); DDEESSCCRRIIPPTTIIOONN The ffsseeeekk() function sets the file position indicator for the stream pointed to by _s_t_r_e_a_m. The new position, measured in bytes, is obtained by 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 to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to the start of the file, the current position indicator, or end-of-file, respective- ly. A successful call to the ffsseeeekk() function clears the end-of-file in- dicator for the stream and undoes any effects of the ungetc(3) function on the same stream. The fftteellll() function obtains the current value of the file position indi- cator for the stream pointed to by _s_t_r_e_a_m. The rreewwiinndd() function sets the file position indicator for the stream pointed to by _s_t_r_e_a_m to the beginning of the file. It is equivalent to: (void)fseek(stream, 0L, SEEK_SET) except that the error indicator for the stream is also cleared (see clearerr(3)). The ffggeettppooss() and ffsseettppooss() functions are alternate interfaces equivalent to fftteellll() and ffsseeeekk() (with whence set to SEEK_SET ), setting and stor- ing the current value of the file offset into or from the object refer- enced by _p_o_s. On some (non-UNIX) systems an ``_f_p_o_s___t'' object may be a complex object and these routines may be the only way to portably reposi- tion a text stream. RREETTUURRNN VVAALLUUEESS The rreewwiinndd() function returns no value. Upon successful completion, ffggeettppooss(), ffsseeeekk(), ffsseettppooss() return 0, and fftteellll() returns the current offset. Otherwise, -1 is returned and the global variable errno is set to indicate the error. EERRRROORRSS [EBADF] The _s_t_r_e_a_m specified is not a seekable stream. [EINVAL] The _w_h_e_n_c_e argument to ffsseeeekk() was not SEEK_SET, SEEK_END, or SEEK_CUR. The function ffggeettppooss(), ffsseeeekk(), ffsseettppooss(), and fftteellll() may also fail and set _e_r_r_n_o for any of the errors specified for the routines fflush(3), fstat(2), lseek(2), and malloc(3). SSEEEE AALLSSOO lseek(2) SSTTAANNDDAARRDDSS The ffggeettppooss(), ffsseettppooss(), ffsseeeekk(), fftteellll(), and rreewwiinndd() functions con- form to ANSI C X3.159-1989 (``ANSI C ''). 4.4BSD June 4, 1993 2