Home | History | Annotate | Line # | Download | only in stdio
mkdtemp.c revision 1.10.4.2
      1  1.10.4.2  apb /*	$NetBSD: mkdtemp.c,v 1.10.4.2 2008/10/20 10:28:39 apb Exp $	*/
      2  1.10.4.2  apb 
      3  1.10.4.2  apb /*
      4  1.10.4.2  apb  * Copyright (c) 1987, 1993
      5  1.10.4.2  apb  *	The Regents of the University of California.  All rights reserved.
      6  1.10.4.2  apb  *
      7  1.10.4.2  apb  * Redistribution and use in source and binary forms, with or without
      8  1.10.4.2  apb  * modification, are permitted provided that the following conditions
      9  1.10.4.2  apb  * are met:
     10  1.10.4.2  apb  * 1. Redistributions of source code must retain the above copyright
     11  1.10.4.2  apb  *    notice, this list of conditions and the following disclaimer.
     12  1.10.4.2  apb  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.10.4.2  apb  *    notice, this list of conditions and the following disclaimer in the
     14  1.10.4.2  apb  *    documentation and/or other materials provided with the distribution.
     15  1.10.4.2  apb  * 3. Neither the name of the University nor the names of its contributors
     16  1.10.4.2  apb  *    may be used to endorse or promote products derived from this software
     17  1.10.4.2  apb  *    without specific prior written permission.
     18  1.10.4.2  apb  *
     19  1.10.4.2  apb  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     20  1.10.4.2  apb  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21  1.10.4.2  apb  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22  1.10.4.2  apb  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     23  1.10.4.2  apb  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24  1.10.4.2  apb  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25  1.10.4.2  apb  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26  1.10.4.2  apb  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27  1.10.4.2  apb  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28  1.10.4.2  apb  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29  1.10.4.2  apb  * SUCH DAMAGE.
     30  1.10.4.2  apb  */
     31  1.10.4.2  apb 
     32  1.10.4.2  apb #if HAVE_NBTOOL_CONFIG_H
     33  1.10.4.2  apb #include "nbtool_config.h"
     34  1.10.4.2  apb #endif
     35  1.10.4.2  apb 
     36  1.10.4.2  apb #if !HAVE_NBTOOL_CONFIG_H || !HAVE_MKDTEMP
     37  1.10.4.2  apb 
     38  1.10.4.2  apb #include <sys/cdefs.h>
     39  1.10.4.2  apb #if defined(LIBC_SCCS) && !defined(lint)
     40  1.10.4.2  apb #if 0
     41  1.10.4.2  apb static char sccsid[] = "@(#)mktemp.c	8.1 (Berkeley) 6/4/93";
     42  1.10.4.2  apb #else
     43  1.10.4.2  apb __RCSID("$NetBSD: mkdtemp.c,v 1.10.4.2 2008/10/20 10:28:39 apb Exp $");
     44  1.10.4.2  apb #endif
     45  1.10.4.2  apb #endif /* LIBC_SCCS and not lint */
     46  1.10.4.2  apb 
     47  1.10.4.2  apb #if HAVE_NBTOOL_CONFIG_H
     48  1.10.4.2  apb #define	GETTEMP		__nbcompat_gettemp
     49  1.10.4.2  apb #else
     50  1.10.4.2  apb #include <assert.h>
     51  1.10.4.2  apb #include <errno.h>
     52  1.10.4.2  apb #include <stdio.h>
     53  1.10.4.2  apb #include <stdlib.h>
     54  1.10.4.2  apb #include <unistd.h>
     55  1.10.4.2  apb #include "reentrant.h"
     56  1.10.4.2  apb #include "local.h"
     57  1.10.4.2  apb #define	GETTEMP		__gettemp
     58  1.10.4.2  apb #endif
     59  1.10.4.2  apb 
     60  1.10.4.2  apb char *
     61  1.10.4.2  apb mkdtemp(path)
     62  1.10.4.2  apb 	char *path;
     63  1.10.4.2  apb {
     64  1.10.4.2  apb 	_DIAGASSERT(path != NULL);
     65  1.10.4.2  apb 
     66  1.10.4.2  apb 	return (GETTEMP(path, (int *)NULL, 1) ? path : (char *)NULL);
     67  1.10.4.2  apb }
     68  1.10.4.2  apb 
     69  1.10.4.2  apb #endif /* !HAVE_NBTOOL_CONFIG_H || !HAVE_MKDTEMP */
     70