getsubopt.h is replaced with <stdlib.h>.
[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 #if defined __need_malloc_and_calloc
20 /* Special invocation convention inside glibc header files.  */
21 #include @ABSOLUTE_STDLIB_H@
22 #else
23 /* Normal invocation convention.  */
24 #ifndef _GL_STDLIB_H
25 #define _GL_STDLIB_H
26
27 #include @ABSOLUTE_STDLIB_H@
28
29
30 /* The definition of GL_LINK_WARNING is copied here.  */
31
32
33 /* Some systems do not define EXIT_*, despite otherwise supporting C89.  */
34 #ifndef EXIT_SUCCESS
35 # define EXIT_SUCCESS 0
36 #endif
37 #ifndef EXIT_FAILURE
38 # define EXIT_FAILURE 1
39 #endif
40
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46
47 #if @GNULIB_GETSUBOPT@
48 /* Assuming *OPTIONP is a comma separated list of elements of the form
49    "token" or "token=value", getsubopt parses the first of these elements.
50    If the first element refers to a "token" that is member of the given
51    NULL-terminated array of tokens:
52      - It replaces the comma with a NUL byte, updates *OPTIONP to point past
53        the first option and the comma, sets *VALUEP to the value of the
54        element (or NULL if it doesn't contain an "=" sign),
55      - It returns the index of the "token" in the given array of tokens.
56    Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
57    For more details see the POSIX:2001 specification.
58    http://www.opengroup.org/susv3xsh/getsubopt.html */
59 # if !@HAVE_GETSUBOPT@
60 extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
61 # endif
62 #elif defined GNULIB_POSIXCHECK
63 # undef getsubopt
64 # define getsubopt(o,t,v) \
65     (GL_LINK_WARNING ("getsubopt is unportable - "\
66                       "use gnulib module getsubopt for portability"), \
67      getsubopt (o, t, v))
68 #endif
69
70
71 #if @GNULIB_MKDTEMP@
72 # if !@HAVE_MKDTEMP@
73 /* Create a unique temporary directory from TEMPLATE.
74    The last six characters of TEMPLATE must be "XXXXXX";
75    they are replaced with a string that makes the directory name unique.
76    Returns TEMPLATE, or a null pointer if it cannot get a unique name.
77    The directory is created mode 700.  */
78 extern char * mkdtemp (char *template);
79 # endif
80 #elif defined GNULIB_POSIXCHECK
81 # undef mkdtemp
82 # define mkdtemp(t) \
83     (GL_LINK_WARNING ("mkdtemp is unportable - "\
84                       "use gnulib module mkdtemp for portability"), \
85      mkdtemp (t))
86 #endif
87
88
89 #if @GNULIB_MKSTEMP@
90 # if @REPLACE_MKSTEMP@
91 /* Create a unique temporary file from TEMPLATE.
92    The last six characters of TEMPLATE must be "XXXXXX";
93    they are replaced with a string that makes the file name unique.
94    The file is then created, ensuring it didn't exist before.
95    The file is created read-write (mask at least 0600 & ~umask), but it may be
96    world-readable and world-writable (mask 0666 & ~umask), depending on the
97    implementation.
98    Returns the open file descriptor if successful, otherwise -1 and errno
99    set.  */
100 #  define mkstemp rpl_mkstemp
101 extern int mkstemp (char *template);
102 # endif
103 #elif defined GNULIB_POSIXCHECK
104 # undef mkstemp
105 # define mkstemp(t) \
106     (GL_LINK_WARNING ("mkstemp is unportable - "\
107                       "use gnulib module mkstemp for portability"), \
108      mkstemp (t))
109 #endif
110
111
112 #ifdef __cplusplus
113 }
114 #endif
115
116 #endif /* _GL_STDLIB_H */
117 #endif