New module 'stdlib'.
[gnulib.git] / lib / stdlib_.h
1 /* A GNU-like <stdlib.h>.
2
3    Copyright (C) 1995, 2001-2002, 2006-2007 Free Software Foundation, Inc.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 #ifndef _GL_STDLIB_H
20 #define _GL_STDLIB_H
21
22 #include @ABSOLUTE_STDLIB_H@
23
24
25 /* The definition of GL_LINK_WARNING is copied here.  */
26
27
28 /* Some systems do not define EXIT_*, despite otherwise supporting C89.  */
29 #ifndef EXIT_SUCCESS
30 # define EXIT_SUCCESS 0
31 #endif
32 #ifndef EXIT_FAILURE
33 # define EXIT_FAILURE 1
34 #endif
35
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41
42 #if @GNULIB_MKDTEMP@
43 # if !@HAVE_MKDTEMP@
44 /* Create a unique temporary directory from TEMPLATE.
45    The last six characters of TEMPLATE must be "XXXXXX";
46    they are replaced with a string that makes the directory name unique.
47    Returns TEMPLATE, or a null pointer if it cannot get a unique name.
48    The directory is created mode 700.  */
49 extern char * mkdtemp (char *template);
50 # endif
51 #elif defined GNULIB_POSIXCHECK
52 # undef mkdtemp
53 # define mkdtemp(t) \
54     (GL_LINK_WARNING ("mkdtemp is unportable - "\
55                       "use gnulib module mkdtemp for portability"), \
56      mkdtemp (t))
57 #endif
58
59 #if @GNULIB_MKSTEMP@
60 # if @REPLACE_MKSTEMP@
61 /* Create a unique temporary file from TEMPLATE.
62    The last six characters of TEMPLATE must be "XXXXXX";
63    they are replaced with a string that makes the file name unique.
64    The file is then created, ensuring it didn't exist before.
65    The file is created read-write (mask at least 0600 & ~umask), but it may be
66    world-readable and world-writable (mask 0666 & ~umask), depending on the
67    implementation.
68    Returns the open file descriptor if successful, otherwise -1 and errno
69    set.  */
70 #  define mkstemp rpl_mkstemp
71 extern int mkstemp (char *template);
72 # endif
73 #elif defined GNULIB_POSIXCHECK
74 # undef mkstemp
75 # define mkstemp(t) \
76     (GL_LINK_WARNING ("mkstemp is unportable - "\
77                       "use gnulib module mkstemp for portability"), \
78      mkstemp (t))
79 #endif
80
81
82 #ifdef __cplusplus
83 }
84 #endif
85
86 #endif