4.3BSD-Reno/share/man/cat3/tmpnam.0

Compare this file to the similar file:
Show the results in this format:




TMPFILE(3)		      1990		       TMPFILE(3)



NNAAMMEE
     tempnam, tmpfile, tmpnam - temporary file routines

SSYYNNOOPPSSIISS
     ##iinncclluuddee <<ssttddiioo..hh>>

     FFIILLEE **
     ttmmppffiillee((vvooiidd));;

     cchhaarr **
     ttmmppnnaamm((cchhaarr **ssttrr));;

     cchhaarr **
     tteemmppnnaamm((ccoonnsstt cchhaarr **ttmmppddiirr,, ccoonnsstt cchhaarr **pprreeffiixx));;

DDEESSCCRRIIPPTTIIOONN
     _T_m_p_f_i_l_e opens a file using a file name generated by the rou-
     tine _t_m_p_n_a_m(3), and returns a pointer to the stream associ-
     ated with the file.  The created file is unlinked before
     _t_m_p_f_i_l_e returns, causing the contents of the file to be
     deleted automatically when the last reference to it is
     closed.  The file is opened with the access value ``w+''.
     If _t_m_p_n_a_m returns NULL, or if _t_m_p_f_i_l_e is unable to open the
     file, a NULL pointer is returned.

     _T_m_p_n_a_m returns a pointer to a file name, in the directory
     ``/usr/tmp'', which did not reference an existing file at
     some indeterminate point in the past.  If the argument _s is
     non-NULL, this file name is copied to the buffer it refer-
     ences.  Otherwise, memory to contain this file name is allo-
     cated by _t_m_p_n_a_m.  In either case, _t_m_p_n_a_m returns a pointer
     to the file name; in the latter case, the return value may
     be used as a subsequent argument to _f_r_e_e(3).

     In the current implementation, the memory buffer referenced
     by _s must be at least 16 bytes long.

     _T_e_m_p_n_a_m is similar to _t_m_p_n_a_m, but provides the ability to
     specify the directory which will contain the temporary file
     and the file name prefix.

     The environmental variable ``TMPDIR'' (if set), the argument
     _d_i_r (if non-NULL), the directory ``/usr/tmp'' and the direc-
     tory ``/tmp'' are tried, in the listed order, as directories
     in which to store the temporary file.  _T_e_m_p_n_a_m allocates
     memory in which to store the file name; the returned pointer
     may be used as a subsequent argument to _f_r_e_e(3).  The argu-
     ment _p_r_e_f_i_x, if non-NULL, is used to specify a file name
     prefix, which will be the first part of the created file
     name.





Printed 7/27/90               June				1






TMPFILE(3)		      1990		       TMPFILE(3)



     _T_m_p_n_a_m and _t_e_m_p_n_a_m_e return a NULL pointer if unable to allo-
     cate memory or find a file which may be created.

     The manifest constants ``TMP_MAX'', ``P_tmpdir'' and
     ``L_tmpnam'', documented for the routines _t_m_p_n_a_m and _t_e_m_p_n_a_m
     in other systems, are not available in this implementation.
     If the source code requires them, simply use:

	  #define   TMP_MAX	   308915776
	  #define   P_tmpdir	   "/usr/tmp"
	  #define   L_tmpnam	   1024

BBUUGGSS
     These interfaces are provided for System V compatibility
     only.  The _m_k_s_t_e_m_p(3) interface is strongly preferred.

     There are three important problems with these interfaces (as
     well as with the historic _m_k_t_e_m_p(3) interface).  First,
     there is an obvious race between file name selection and
     file creation.  Second, most implementations provide only a
     limited number (usually 26) of possible temporary file names
     before file names will start being recycled.  Third, the
     System V implementations of these functions (and _m_k_t_e_m_p) use
     the _a_c_c_e_s_s(2) system call to determine whether or not the
     temporary file may be created.  This has obvious ramifica-
     tions for setuid or setgid programs, complicating the port-
     able use of these interfaces in such programs.

     The _m_k_s_t_e_m_p(3) interface has none of these problems; the
     _m_k_t_e_m_p(_3) implementation in this system suffers only from
     the race condition described above.

     The _t_m_p_f_i_l_e interface should not be used if there is any
     possibility that the user does not wish the temporary file
     to be publicly readable or writable.

SSEEEE AALLSSOO
     fopen(3), mkstemp(3), mktemp(3)

















Printed 7/27/90               June				2