BSD 4_4 development
[unix-history] / usr / share / man / cat3 / tempnam.0
index 09cd3bd..ae9327b 100644 (file)
-
-
-
-TMPFILE(3)                   1990                     TMPFILE(3)
-
-
+TMPFILE(3)                  BSD Programmer's Manual                 TMPFILE(3)
 
 N\bNA\bAM\bME\bE
 
 N\bNA\bAM\bME\bE
-     tempnam, tmpfile, tmpnam - temporary file routines
+     t\bte\bem\bmp\bpn\bna\bam\bm, t\btm\bmp\bpf\bfi\bil\ble\be, t\btm\bmp\bpn\bna\bam\bm - temporary file routines
 
 S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
      #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bst\btd\bdi\bio\bo.\b.h\bh>\b>
 
 
 S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
      #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bst\btd\bdi\bio\bo.\b.h\bh>\b>
 
-     F\bFI\bIL\bLE\bE *\b*
-     t\btm\bmp\bpf\bfi\bil\ble\be(\b(v\bvo\boi\bid\bd)\b);\b;
+     _\bF_\bI_\bL_\bE _\b*
+     t\btm\bmp\bpf\bfi\bil\ble\be(_\bv_\bo_\bi_\bd);
 
 
-     c\bch\bha\bar\br *\b*
-     t\btm\bmp\bpn\bna\bam\bm(\b(c\bch\bha\bar\br *\b*s\bst\btr\br)\b);\b;
+     _\bc_\bh_\ba_\br _\b*
+     t\btm\bmp\bpn\bna\bam\bm(_\bc_\bh_\ba_\br _\b*_\bs_\bt_\br);
 
 
-     c\bch\bha\bar\br *\b*
-     t\bte\bem\bmp\bpn\bna\bam\bm(\b(c\bco\bon\bns\bst\bt c\bch\bha\bar\br *\b*t\btm\bmp\bpd\bdi\bir\br,\b, c\bco\bon\bns\bst\bt c\bch\bha\bar\br *\b*p\bpr\bre\bef\bfi\bix\bx)\b);\b;
+     _\bc_\bh_\ba_\br _\b*
+     t\bte\bem\bmp\bpn\bna\bam\bm(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bt_\bm_\bp_\bd_\bi_\br, _\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\br_\be_\bf_\bi_\bx);
 
 D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
 
 D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
-     _\bT_\bm_\bp_\bf_\bi_\bl_\be opens a file using a file name generated by the rou-
-     tine _\bt_\bm_\bp_\bn_\ba_\bm(3), and returns a pointer to the stream associ-
-     ated with the file.  The created file is unlinked before
-     _\bt_\bm_\bp_\bf_\bi_\bl_\be 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 _\bt_\bm_\bp_\bn_\ba_\bm returns NULL, or if _\bt_\bm_\bp_\bf_\bi_\bl_\be is unable to open the
-     file, a NULL pointer is returned.
-
-     _\bT_\bm_\bp_\bn_\ba_\bm 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 _\bs 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 _\bt_\bm_\bp_\bn_\ba_\bm.  In either case, _\bt_\bm_\bp_\bn_\ba_\bm returns a pointer
-     to the file name; in the latter case, the return value may
-     be used as a subsequent argument to _\bf_\br_\be_\be(3).
-
-     In the current implementation, the memory buffer referenced
-     by _\bs must be at least 16 bytes long.
-
-     _\bT_\be_\bm_\bp_\bn_\ba_\bm is similar to _\bt_\bm_\bp_\bn_\ba_\bm, 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
-     _\bd_\bi_\br (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.  _\bT_\be_\bm_\bp_\bn_\ba_\bm allocates
-     memory in which to store the file name; the returned pointer
-     may be used as a subsequent argument to _\bf_\br_\be_\be(3).  The argu-
-     ment _\bp_\br_\be_\bf_\bi_\bx, if non-NULL, is used to specify a file name
-     prefix, which will be the first part of the created file
-     name.
+     The t\btm\bmp\bpf\bfi\bil\ble\be() function returns a pointer to a stream associated with a
+     file descriptor returned by the routine mkstemp(3).  The created file is
+     unlinked before t\btm\bmp\bpf\bfi\bil\ble\be() returns, causing the file to be automatically
+     deleted when the last reference to it is closed.  The file is opened with
+     the access value `w+'.
 
 
+     The t\btm\bmp\bpn\bna\bam\bm() function returns a pointer to a file name, in the P_tmpdir
+     directory, which did not reference an existing file at some indeterminate
+     point in the past.  P_tmpdir is defined in the include file <_\bs_\bt_\bd_\bi_\bo_\b._\bh>. If
+     the argument _\bs is non-NULL, the file name is copied to the buffer it ref-
+     erences.  Otherwise, the file name is copied to a static buffer.  In ei-
+     ther case, t\btm\bmp\bpn\bna\bam\bm() returns a pointer to the file name.
 
 
+     The buffer referenced by _\bs is expected to be at least L_tmpnam bytes in
+     length.  L_tmpnam is defined in the include file <_\bs_\bt_\bd_\bi_\bo_\b._\bh>.
 
 
+     The t\bte\bem\bmp\bpn\bna\bam\bm() function is similar to t\btm\bmp\bpn\bna\bam\bm(), but provides the ability
+     to specify the directory which will contain the temporary file and the
+     file name prefix.
 
 
+     The environment variable TMPDIR (if set), the argument _\bd_\bi_\br (if non-NULL),
+     the directory P_tmpdir, and the directory _\b/_\bt_\bm_\bp are tried, in the listed
+     order, as directories in which to store the temporary file.
 
 
-Printed 7/27/90               June                             1
+     The argument _\bp_\br_\be_\bf_\bi_\bx, if non-NULL, is used to specify a file name prefix,
+     which will be the first part of the created file name.  T\bTe\bem\bmp\bpn\bna\bam\bm() allo-
+     cates memory in which to store the file name; the returned pointer may be
+     used as a subsequent argument to free(3).
 
 
+R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
+     The t\btm\bmp\bpf\bfi\bil\ble\be() function returns a pointer to an open file stream on suc-
+     cess, and a NULL pointer on error.
 
 
+     The t\btm\bmp\bpn\bna\bam\bm() and t\bte\bem\bmp\bpf\bfi\bil\ble\be() functions return a pointer to a file name on
+     success, and a NULL pointer on error.
 
 
+E\bER\bRR\bRO\bOR\bRS\bS
+     The t\btm\bmp\bpf\bfi\bil\ble\be() function may fail and set the global variable _\be_\br_\br_\bn_\bo for any
+     of the errors specified for the library functions fdopen(3) or
+     mkstemp(3).
 
 
+     The t\btm\bmp\bpn\bna\bam\bm() function may fail and set _\be_\br_\br_\bn_\bo for any of the errors speci-
+     fied for the library function mktemp(3).
 
 
-
-TMPFILE(3)                   1990                     TMPFILE(3)
-
-
-
-     _\bT_\bm_\bp_\bn_\ba_\bm and _\bt_\be_\bm_\bp_\bn_\ba_\bm_\be 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 _\bt_\bm_\bp_\bn_\ba_\bm and _\bt_\be_\bm_\bp_\bn_\ba_\bm
-     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
-
-B\bBU\bUG\bGS\bS
-     These interfaces are provided for System V compatibility
-     only.  The _\bm_\bk_\bs_\bt_\be_\bm_\bp(3) interface is strongly preferred.
-
-     There are three important problems with these interfaces (as
-     well as with the historic _\bm_\bk_\bt_\be_\bm_\bp(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 _\bm_\bk_\bt_\be_\bm_\bp) use
-     the _\ba_\bc_\bc_\be_\bs_\bs(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 _\bm_\bk_\bs_\bt_\be_\bm_\bp(3) interface has none of these problems; the
-     _\bm_\bk_\bt_\be_\bm_\bp(_\b3) implementation in this system suffers only from
-     the race condition described above.
-
-     The _\bt_\bm_\bp_\bf_\bi_\bl_\be 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.
+     The t\bte\bem\bmp\bpn\bna\bam\bm() function may fail and set _\be_\br_\br_\bn_\bo for any of the errors spec-
+     ified for the library functions malloc(3) or mktemp(3).
 
 S\bSE\bEE\bE A\bAL\bLS\bSO\bO
 
 S\bSE\bEE\bE A\bAL\bLS\bSO\bO
-     fopen(3), mkstemp(3), mktemp(3)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Printed 7/27/90               June                             2
-
+     mkstemp(3),  mktemp(3)
 
 
+S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
+     The t\btm\bmp\bpf\bfi\bil\ble\be() and t\btm\bmp\bpn\bna\bam\bm() functions conform to ANSI C X3.159-1989
+     (``ANSI C '').
 
 
+B\bBU\bUG\bGS\bS
+     These interfaces are provided for System V and ANSI compatibility only.
+     The mkstemp(3) interface is strongly preferred.
+
+     There are four important problems with these interfaces (as well as with
+     the historic mktemp(3) interface).  First, there is an obvious race be-
+     tween file name selection and file creation and deletion.  Second, most
+     historic implementations provide only a limited number of possible tempo-
+     rary file names (usually 26) before file names will start being recycled.
+     Third, the System V implementations of these functions (and of mktemp)
+     use the access(2) function to determine whether or not the temporary file
+     may be created.  This has obvious ramifications for setuid or setgid pro-
+     grams, complicating the portable use of these interfaces in such pro-
+     grams.  Finally, there is no specification of the permissions with which
+     the temporary files are created.
+
+     This implementation does not have these flaws, but portable software can-
+     not depend on that.  In particular, the t\btm\bmp\bpf\bfi\bil\ble\be() interface should not be
+     used in software expected to be used on other systems if there is any
+     possibility that the user does not wish the temporary file to be publicly
+     readable and writable.
+
+4.4BSD                           June 4, 1993                                2