* modules/mkostemps: New module.
* modules/mkstemps: Likewise.
* lib/mkostemps.c (mkostemps): New file.
* lib/mkstemps.c (mkstemps): Likewise.
* m4/mkostemps.m4 (gl_FUNC_MKOSTEMPS): Likewise.
* m4/mkstemps.m4 (gl_FUNC_MKSTEMPS): Likewise.
* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Add witnesses.
* modules/stdlib (Makefile.am): Substitute them.
* lib/stdlib.in.h (mkostemps, mkstemps): Declare them.
* doc/glibc-functions/mkstemps.texi (mkstemps): New file.
* doc/glibc-functions/mkostemps.texi (mkostemps): Likewise.
* doc/gnulib.texi (Glibc stdlib.h): Include them.
* MODULES.html.sh (File system functions): Mention them.
Signed-off-by: Eric Blake <ebb9@byu.net>
2009-11-04 Eric Blake <ebb9@byu.net>
+ mkstemps, mkostemps: new modules
+ * modules/mkostemps: New module.
+ * modules/mkstemps: Likewise.
+ * lib/mkostemps.c (mkostemps): New file.
+ * lib/mkstemps.c (mkstemps): Likewise.
+ * m4/mkostemps.m4 (gl_FUNC_MKOSTEMPS): Likewise.
+ * m4/mkstemps.m4 (gl_FUNC_MKSTEMPS): Likewise.
+ * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Add witnesses.
+ * modules/stdlib (Makefile.am): Substitute them.
+ * lib/stdlib.in.h (mkostemps, mkstemps): Declare them.
+ * doc/glibc-functions/mkstemps.texi (mkstemps): New file.
+ * doc/glibc-functions/mkostemps.texi (mkostemps): Likewise.
+ * doc/gnulib.texi (Glibc stdlib.h): Include them.
+ * MODULES.html.sh (File system functions): Mention them.
+
tempname: resync from glibc
* lib/tempname.c (__gen_tempname): Add suffixlen argument. Use
same values for __GT_FILE as glibc. Abort even when assertions
func_module mkancesdirs
func_module mkfifoat
func_module mkdir-p
+ func_module mkostemp
+ func_module mkostemps
+ func_module mkstemps
func_module modechange
func_module mountlist
func_module openat
--- /dev/null
+@node mkostemps
+@subsection @code{mkostemps}
+@findex mkostemps
+
+Gnulib module: mkostemps
+
+Portability problems fixed by Gnulib:
+@itemize
+@item
+This function is missing on all non-glibc platforms:
+glibc 2.10, MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin, mingw, Interix 3.5, BeOS.
+@end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
--- /dev/null
+@node mkstemps
+@subsection @code{mkstemps}
+@findex mkstemps
+
+Gnulib module: mkstemps
+
+Portability problems fixed by Gnulib:
+@itemize
+@item
+This function is missing on many non-glibc platforms:
+glibc 2.10, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin
+1.5.x, mingw, Interix 3.5, BeOS.
+@end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
* lcong48_r::
* lrand48_r::
* mkostemp::
+* mkostemps::
* mrand48_r::
+* mkstemps::
* nrand48_r::
* on_exit::
* ptsname_r::
@include glibc-functions/lcong48_r.texi
@include glibc-functions/lrand48_r.texi
@include glibc-functions/mkostemp.texi
+@include glibc-functions/mkostemps.texi
@include glibc-functions/mrand48_r.texi
+@include glibc-functions/mkstemps.texi
@include glibc-functions/nrand48_r.texi
@include glibc-functions/on_exit.texi
@include glibc-functions/ptsname_r.texi
--- /dev/null
+/* Copyright (C) 1998, 1999, 2001, 2005, 2006, 2007, 2009 Free
+ Software Foundation, Inc.
+ This file is derived from the one in the GNU C Library.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#if !_LIBC
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+
+#if !_LIBC
+# include <errno.h>
+# include "tempname.h"
+# define __gen_tempname gen_tempname
+# ifndef __GT_FILE
+# define __GT_FILE GT_FILE
+# endif
+# define __set_errno(x) errno = x;
+#endif
+
+#include <stdio.h>
+
+#ifndef __GT_FILE
+# define __GT_FILE 0
+#endif
+
+/* Generate a unique temporary file name from TEMPLATE. The last six
+ characters before a suffix of length SUFFIXLEN of TEMPLATE must be
+ "XXXXXX"; they are replaced with a string that makes the filename
+ unique. Then open the file and return a fd. */
+int
+mkostemps (template, suffixlen, flags)
+ char *template;
+ int suffixlen;
+ int flags;
+{
+ if (suffixlen < 0)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return __gen_tempname (template, suffixlen, flags, __GT_FILE);
+}
--- /dev/null
+/* Copyright (C) 1998, 1999, 2001, 2005, 2006, 2007, 2009 Free
+ Software Foundation, Inc.
+ This file is derived from the one in the GNU C Library.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#if !_LIBC
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+
+#if !_LIBC
+# include <errno.h>
+# include "tempname.h"
+# define __gen_tempname gen_tempname
+# ifndef __GT_FILE
+# define __GT_FILE GT_FILE
+# endif
+# define __set_errno(x) errno = x;
+#endif
+
+#include <stdio.h>
+
+#ifndef __GT_FILE
+# define __GT_FILE 0
+#endif
+
+/* Generate a unique temporary file name from TEMPLATE. The last six
+ characters before a suffix of length SUFFIXLEN of TEMPLATE must be
+ "XXXXXX"; they are replaced with a string that makes the filename
+ unique. Then open the file and return a fd. */
+int
+mkstemps (template, suffixlen)
+ char *template;
+ int suffixlen;
+{
+ if (suffixlen < 0)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return __gen_tempname (template, suffixlen, 0, __GT_FILE);
+}
mkostemp (t, f))
#endif
+#if @GNULIB_MKOSTEMPS@
+# if !@HAVE_MKOSTEMPS@
+/* Create a unique temporary file from TEMPLATE.
+ The last six characters of TEMPLATE before a suffix of length
+ SUFFIXLEN must be "XXXXXX";
+ they are replaced with a string that makes the file name unique.
+ The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+ and O_TEXT, O_BINARY (defined in "binary-io.h").
+ The file is then created, with the specified flags, ensuring it didn't exist
+ before.
+ The file is created read-write (mask at least 0600 & ~umask), but it may be
+ world-readable and world-writable (mask 0666 & ~umask), depending on the
+ implementation.
+ Returns the open file descriptor if successful, otherwise -1 and errno
+ set. */
+extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mkostemps
+# define mkostemps(t,s,f) \
+ (GL_LINK_WARNING ("mkostemps is unportable - " \
+ "use gnulib module mkostemps for portability"), \
+ mkostemps (t, s, f))
+#endif
+
#if @GNULIB_MKSTEMP@
# if @REPLACE_MKSTEMP@
/* Create a unique temporary file from TEMPLATE.
mkstemp (t))
#endif
+#if @GNULIB_MKSTEMPS@
+# if !@HAVE_MKSTEMPS@
+/* Create a unique temporary file from TEMPLATE.
+ The last six characters of TEMPLATE prior to a suffix of length
+ SUFFIXLEN must be "XXXXXX";
+ they are replaced with a string that makes the file name unique.
+ The file is then created, ensuring it didn't exist before.
+ The file is created read-write (mask at least 0600 & ~umask), but it may be
+ world-readable and world-writable (mask 0666 & ~umask), depending on the
+ implementation.
+ Returns the open file descriptor if successful, otherwise -1 and errno
+ set. */
+extern int mkstemps (char * /*template*/, int /*suffixlen*/);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mkstemps
+# define mkstemps(t,s) \
+ (GL_LINK_WARNING ("mkstemps is unportable - " \
+ "use gnulib module mkstemps for portability"), \
+ mkstemps (t, s))
+#endif
+
#if @GNULIB_PUTENV@
# if @REPLACE_PUTENV@
# undef putenv
--- /dev/null
+# mkostemps.m4 serial 1
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_MKOSTEMPS],
+[
+ AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+
+ dnl Persuade glibc <stdlib.h> to declare mkostemps().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ AC_CHECK_FUNCS_ONCE([mkostemps])
+ if test $ac_cv_func_mkostemps != yes; then
+ HAVE_MKOSTEMPS=0
+ AC_LIBOBJ([mkostemps])
+ fi
+])
--- /dev/null
+# mkstemps.m4 serial 1
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_MKSTEMPS],
+[
+ AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+
+ dnl Persuade glibc <stdlib.h> to declare mkstemps().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ AC_CHECK_FUNCS_ONCE([mkstemps])
+ if test $ac_cv_func_mkstemps != yes; then
+ HAVE_MKSTEMPS=0
+ AC_LIBOBJ([mkstemps])
+ fi
+])
-# stdlib_h.m4 serial 20
+# stdlib_h.m4 serial 21
dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX])
GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP])
GNULIB_MKOSTEMP=0; AC_SUBST([GNULIB_MKOSTEMP])
+ GNULIB_MKOSTEMPS=0; AC_SUBST([GNULIB_MKOSTEMPS])
GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP])
+ GNULIB_MKSTEMPS=0; AC_SUBST([GNULIB_MKSTEMPS])
GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV])
GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R])
GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
HAVE_MALLOC_POSIX=1; AC_SUBST([HAVE_MALLOC_POSIX])
HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP])
+ HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS])
+ HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS])
HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
HAVE_REALLOC_POSIX=1; AC_SUBST([HAVE_REALLOC_POSIX])
HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH])
--- /dev/null
+Description:
+mkostemps() function: create a private temporary file, with specific opening
+flags, and with suffix.
+
+Files:
+lib/mkostemps.c
+m4/mkostemps.m4
+
+Depends-on:
+extensions
+stdlib
+tempname
+
+configure.ac:
+gl_FUNC_MKOSTEMPS
+gl_STDLIB_MODULE_INDICATOR([mkostemps])
+
+Makefile.am:
+
+Include:
+<stdlib.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Eric Blake
--- /dev/null
+Description:
+mkstemps() function: create a private temporary file, with suffix
+
+Files:
+lib/mkstemps.c
+m4/mkstemps.m4
+
+Depends-on:
+extensions
+stdlib
+tempname
+
+configure.ac:
+gl_FUNC_MKSTEMPS
+gl_STDLIB_MODULE_INDICATOR([mkstemps])
+
+Makefile.am:
+
+Include:
+<stdlib.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Eric Blake
-e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
-e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
-e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \
+ -e 's|@''GNULIB_MKOSTEMPS''@|$(GNULIB_MKOSTEMPS)|g' \
-e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
+ -e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \
-e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
-e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
-e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
-e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \
-e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
-e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
+ -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
+ -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
-e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
-e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
-e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \