home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / man / cat3 / fopen.0 < prev    next >
Text File  |  1993-12-07  |  5KB  |  133 lines

  1.  
  2. FOPEN(3)                   UNIX Programmer's Manual                   FOPEN(3)
  3.  
  4. NNAAMMEE
  5.      ffooppeenn, ffddooppeenn, ffrreeooppeenn - stream open functions
  6.  
  7. SSYYNNOOPPSSIISS
  8.      ##iinncclluuddee <<ssttddiioo..hh>>
  9.  
  10.      _F_I_L_E _*
  11.      ffooppeenn(_c_h_a_r _*_p_a_t_h, _c_h_a_r _*_m_o_d_e)
  12.  
  13.      _F_I_L_E _*
  14.      ffddooppeenn(_i_n_t _f_i_l_d_e_s, _c_h_a_r _*_m_o_d_e)
  15.  
  16.      _F_I_L_E _*
  17.      ffrreeooppeenn(_c_h_a_r _*_p_a_t_h, _c_h_a_r _*_m_o_d_e, _F_I_L_E _*_s_t_r_e_a_m)
  18.  
  19. DDEESSCCRRIIPPTTIIOONN
  20.      The ffooppeenn() function opens the file whose name is the string pointed to
  21.      by _p_a_t_h and associates a stream with it.
  22.  
  23.      The argument _m_o_d_e points to a string beginning with one of the following
  24.      sequences (Additional characters may follow these sequences.):
  25.  
  26.      ``r''   Open text file for reading.  The stream is positioned at the be­
  27.              ginning of the file.
  28.  
  29.      ``r+''  Open for reading and writing.  The stream is positioned at the
  30.              beginning of the file.
  31.  
  32.      ``w''   Truncate file to zero length or create text file for writing.
  33.              The stream is positioned at the beginning of the file.  It ``w+''
  34.              Open for reading and writing.  The file is created if it does not
  35.              exist, otherwise it is truncated.  The stream is positioned at
  36.              the beginning of the file.
  37.  
  38.      ``a''   Open for writing.  The file is created if it does not exist.  The
  39.              stream is positioned at the end of the file.
  40.  
  41.      ``a+''  Open for reading and writing.  The file is created if it does not
  42.              exist.  The stream is positioned at the end of the file.
  43.  
  44.      The _m_o_d_e string can also include the letter ``b'' either as a third char­
  45.      acter or as a character between the characters in any of the two­
  46.      character strings described above.  This is strictly for compatibility
  47.      with ANSI C3.159­1989 (``ANSI C'') and has no effect; the ``b'' is ig­
  48.      nored.
  49.  
  50.      Any created files will have mode "S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP |
  51.      S_IROTH | S_IWOTH" (0666), as modified by the process' umask value (see
  52.      umask(2)).
  53.  
  54.      Reads and writes may be intermixed on read/write streams in any order,
  55.      and do not require an intermediate seek as in previous versions of _s_t_d_i_o.
  56.      This is not portable to other systems, however; ANSI C requires that a
  57.      file positioning function intervene between output and input, unless an
  58.      input operation encounters end­of­file.
  59.  
  60.      The ffddooppeenn() function associates a stream with the existing file descrip­
  61.      tor, _f_i_l_d_e_s. The _m_o_d_e of the stream must be compatible with the mode of
  62.      the file descriptor.
  63.  
  64.      The ffrreeooppeenn() function opens the file whose name is the string pointed to
  65.      by _p_a_t_h and associates the stream pointed to by _s_t_r_e_a_m with it.  The
  66.      original stream (if it exists) is closed.  The _m_o_d_e argument is used just
  67.      as in the fopen function.  The primary use of the ffrreeooppeenn() function is
  68.      to change the file associated with a standard text stream (_s_t_d_e_r_r, _s_t_d_i_n,
  69.      or _s_t_d_o_u_t).
  70.  
  71. RREETTUURRNN VVAALLUUEESS
  72.      Upon successful completion ffooppeenn(), ffddooppeenn() and ffrreeooppeenn() return a FILE
  73.      pointer.  Otherwise, NULL is returned and the global variable _e_r_r_n_o is
  74.      set to indicate the error.
  75.  
  76. EERRRROORRSS
  77.      [EINVAL]  The _m_o_d_e provided to ffooppeenn(), ffddooppeenn(), or ffrreeooppeenn() was in­
  78.                valid.
  79.  
  80.      The ffooppeenn(), ffddooppeenn() and ffrreeooppeenn() functions may also fail and set _e_r_r_n_o
  81.      for any of the errors specified for the routine malloc(3).
  82.  
  83.      The ffooppeenn() function may also fail and set _e_r_r_n_o for any of the errors
  84.      specified for the routine open(2).
  85.  
  86.      The ffddooppeenn() function may also fail and set _e_r_r_n_o for any of the errors
  87.      specified for the routine fcntl(2).
  88.  
  89.      The ffrreeooppeenn() function may also fail and set _e_r_r_n_o for any of the errors
  90.      specified for the routines open(2),  fclose(3) and fflush(3).
  91.  
  92. SSEEEE AALLSSOO
  93.      open(2),  fclose(3),  fseek(3),  funopen(3)
  94.  
  95. SSTTAANNDDAARRDDSS
  96.      The ffooppeenn() and ffrreeooppeenn() functions conform to ANSI C3.159­1989 (``ANSI
  97.      C''). The ffddooppeenn() function conforms to IEEE Std1003.1­1988 (``POSIX'').
  98.  
  99. BSD Experimental                 June 29, 1991                               2
  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.