gnulib: import mkstemp

Older versions of MinGW do not support mkstemp causing:

    gdb/unittests/scoped_fd-selftests.c:37:29: error: \
    'mkstemp' was not declared in this scope
       int fd = mkstemp (filename);
                             ^
    gdb/unittests/scoped_fd-selftests.c: In function 'void
    selftests::scoped_fd::test_release()':
    gdb/unittests/scoped_fd-selftests.c:56:29: error: \
    'mkstemp' was not declared in this scope
       int fd = mkstemp (filename);
                             ^

Import mkstemp from gnulib.

gdb/
	* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add mkstemp.
	* gnulib/aclocal.m4: Regenerated.
	* gnulib/config.in: Regenerated.
	* gnulib/configure: Regenerated.
	* gnulib/import/Makefile.am: Regenerated.
	* gnulib/import/Makefile.in: Regenerated.
	* gnulib/import/m4/gnulib-cache.m4: Regenerated.
	* gnulib/import/m4/gnulib-comp.m4: Regenerated.
	* gnulib/import/m4/mkstemp.m4: Imported.
	* gnulib/import/m4/secure_getenv.m4: Imported.
	* gnulib/import/m4/tempname.m4: Imported.
	* gnulib/import/mkstemp.c: Imported.
	* gnulib/import/secure_getenv.c: Imported.
	* gnulib/import/tempname.c: Imported.
	* gnulib/import/tempname.h: Imported.
This commit is contained in:
Markus Metzger 2018-02-20 11:48:01 +01:00
parent de65820cd6
commit 2d8adcbd07
16 changed files with 938 additions and 21 deletions

View File

@ -1,3 +1,7 @@
2018-02-20 Markus Metzger <markus.t.metzger@intel.com>
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add mkstemp.
2018-02-19 Alan Hayward <alan.hayward@arm.com>
* Makefile.in: (COMMON_SFILES): Add common/*.c files.

View File

@ -1087,6 +1087,7 @@ m4_include([import/m4/memchr.m4])
m4_include([import/m4/memmem.m4])
m4_include([import/m4/mempcpy.m4])
m4_include([import/m4/memrchr.m4])
m4_include([import/m4/mkstemp.m4])
m4_include([import/m4/mmap-anon.m4])
m4_include([import/m4/mode_t.m4])
m4_include([import/m4/msvc-inval.m4])
@ -1106,6 +1107,7 @@ m4_include([import/m4/rename.m4])
m4_include([import/m4/rewinddir.m4])
m4_include([import/m4/rmdir.m4])
m4_include([import/m4/save-cwd.m4])
m4_include([import/m4/secure_getenv.m4])
m4_include([import/m4/setenv.m4])
m4_include([import/m4/signal_h.m4])
m4_include([import/m4/ssize_t.m4])
@ -1125,6 +1127,7 @@ m4_include([import/m4/sys_socket_h.m4])
m4_include([import/m4/sys_stat_h.m4])
m4_include([import/m4/sys_time_h.m4])
m4_include([import/m4/sys_types_h.m4])
m4_include([import/m4/tempname.m4])
m4_include([import/m4/time_h.m4])
m4_include([import/m4/unistd-safer.m4])
m4_include([import/m4/unistd_h.m4])

View File

@ -195,6 +195,9 @@
/* Define to 1 when the gnulib module memrchr should be tested. */
#undef GNULIB_TEST_MEMRCHR
/* Define to 1 when the gnulib module mkstemp should be tested. */
#undef GNULIB_TEST_MKSTEMP
/* Define to 1 when the gnulib module open should be tested. */
#undef GNULIB_TEST_OPEN
@ -228,6 +231,9 @@
/* Define to 1 when the gnulib module rmdir should be tested. */
#undef GNULIB_TEST_RMDIR
/* Define to 1 when the gnulib module secure_getenv should be tested. */
#undef GNULIB_TEST_SECURE_GETENV
/* Define to 1 when the gnulib module setenv should be tested. */
#undef GNULIB_TEST_SETENV
@ -411,9 +417,18 @@
/* Define to 1 if you have the `getdtablesize' function. */
#undef HAVE_GETDTABLESIZE
/* Define to 1 if you have the `getegid' function. */
#undef HAVE_GETEGID
/* Define to 1 if you have the `geteuid' function. */
#undef HAVE_GETEUID
/* Define to 1 if you have the `getexecname' function. */
#undef HAVE_GETEXECNAME
/* Define to 1 if you have the `getgid' function. */
#undef HAVE_GETGID
/* Define to 1 if you have the `getlogin_r' function. */
#undef HAVE_GETLOGIN_R
@ -429,6 +444,9 @@
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
/* Define to 1 if you have the `getuid' function. */
#undef HAVE_GETUID
/* Define to 1 if you have the <glob.h> header file. */
#undef HAVE_GLOB_H
@ -444,6 +462,9 @@
/* Define if the isnan(long double) function is available in libc. */
#undef HAVE_ISNANL_IN_LIBC
/* Define to 1 if you have the `issetugid' function. */
#undef HAVE_ISSETUGID
/* Define to 1 if you have the `iswcntrl' function. */
#undef HAVE_ISWCNTRL
@ -503,6 +524,9 @@
when it succeeds. */
#undef HAVE_MINIMALLY_WORKING_GETCWD
/* Define to 1 if you have the `mkstemp' function. */
#undef HAVE_MKSTEMP
/* Define to 1 if you have the `mprotect' function. */
#undef HAVE_MPROTECT
@ -1370,6 +1394,9 @@
/* Define to 1 if you have the <search.h> header file. */
#undef HAVE_SEARCH_H
/* Define to 1 if you have the `secure_getenv' function. */
#undef HAVE_SECURE_GETENV
/* Define to 1 if you have the `setdtablesize' function. */
#undef HAVE_SETDTABLESIZE
@ -1510,6 +1537,9 @@
/* Define to 1 if you have the `_set_invalid_parameter_handler' function. */
#undef HAVE__SET_INVALID_PARAMETER_HANDLER
/* Define to 1 if you have the `__secure_getenv' function. */
#undef HAVE___SECURE_GETENV
/* Define as the bit index in the word where to find bit 0 of the exponent of
'long double'. */
#undef LDBL_EXPBIT0_BIT

200
gdb/gnulib/configure vendored
View File

@ -3362,8 +3362,14 @@ as_fn_append ac_func_list " mbsinit"
as_fn_append ac_func_list " mbrtowc"
as_fn_append ac_header_list " sys/mman.h"
as_fn_append ac_func_list " mprotect"
as_fn_append ac_func_list " mkstemp"
as_fn_append ac_func_list " openat"
as_fn_append ac_func_list " link"
as_fn_append ac_func_list " secure_getenv"
as_fn_append ac_func_list " getuid"
as_fn_append ac_func_list " geteuid"
as_fn_append ac_func_list " getgid"
as_fn_append ac_func_list " getegid"
as_fn_append ac_func_list " setenv"
as_fn_append ac_func_list " strdup"
as_fn_append ac_func_list " pipe"
@ -5409,6 +5415,7 @@ fi
# Code from module memmem-simple:
# Code from module mempcpy:
# Code from module memrchr:
# Code from module mkstemp:
# Code from module msvc-inval:
# Code from module msvc-nothrow:
# Code from module multiarch:
@ -5428,6 +5435,7 @@ fi
# Code from module rmdir:
# Code from module same-inode:
# Code from module save-cwd:
# Code from module secure_getenv:
# Code from module setenv:
# Code from module signal-h:
# Code from module snippet/_Noreturn:
@ -5454,6 +5462,7 @@ fi
# Code from module sys_stat:
# Code from module sys_time:
# Code from module sys_types:
# Code from module tempname:
# Code from module time:
# Code from module unistd:
# Code from module unistd-safer:
@ -11972,6 +11981,8 @@ _ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for promoted mode_t type" >&5
$as_echo_n "checking for promoted mode_t type... " >&6; }
if test "${gl_cv_promoted_mode_t+set}" = set; then :
@ -12112,6 +12123,16 @@ _ACEOF
ac_fn_c_check_decl "$LINENO" "setenv" "ac_cv_have_decl_setenv" "$ac_includes_default"
if test "x$ac_cv_have_decl_setenv" = x""yes; then :
ac_have_decl=1
@ -19676,6 +19697,117 @@ $as_echo "#define GNULIB_TEST_MEMRCHR 1" >>confdefs.h
if test $ac_cv_func_mkstemp = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mkstemp" >&5
$as_echo_n "checking for working mkstemp... " >&6; }
if test "${gl_cv_func_working_mkstemp+set}" = set; then :
$as_echo_n "(cached) " >&6
else
mkdir conftest.mkstemp
if test "$cross_compiling" = yes; then :
case "$host_os" in
# Guess yes on glibc systems.
*-gnu*) gl_cv_func_working_mkstemp="guessing yes" ;;
# If we don't know, assume the worst.
*) gl_cv_func_working_mkstemp="guessing no" ;;
esac
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
int result = 0;
int i;
off_t large = (off_t) 4294967295u;
if (large < 0)
large = 2147483647;
umask (0);
for (i = 0; i < 70; i++)
{
char templ[] = "conftest.mkstemp/coXXXXXX";
int (*mkstemp_function) (char *) = mkstemp;
int fd = mkstemp_function (templ);
if (fd < 0)
result |= 1;
else
{
struct stat st;
if (lseek (fd, large, SEEK_SET) != large)
result |= 2;
if (fstat (fd, &st) < 0)
result |= 4;
else if (st.st_mode & 0077)
result |= 8;
if (close (fd))
result |= 16;
}
}
return result;
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
gl_cv_func_working_mkstemp=yes
else
gl_cv_func_working_mkstemp=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
rm -rf conftest.mkstemp
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_working_mkstemp" >&5
$as_echo "$gl_cv_func_working_mkstemp" >&6; }
case "$gl_cv_func_working_mkstemp" in
*yes) ;;
*)
REPLACE_MKSTEMP=1
;;
esac
else
HAVE_MKSTEMP=0
fi
if test $HAVE_MKSTEMP = 0 || test $REPLACE_MKSTEMP = 1; then
gl_LIBOBJS="$gl_LIBOBJS mkstemp.$ac_objext"
fi
GNULIB_MKSTEMP=1
$as_echo "#define GNULIB_TEST_MKSTEMP 1" >>confdefs.h
if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
@ -20639,6 +20771,69 @@ $as_echo "#define GNULIB_TEST_RMDIR 1" >>confdefs.h
if test $ac_cv_func_secure_getenv = no; then
HAVE_SECURE_GETENV=0
fi
if test $HAVE_SECURE_GETENV = 0; then
gl_LIBOBJS="$gl_LIBOBJS secure_getenv.$ac_objext"
for ac_func in __secure_getenv
do :
ac_fn_c_check_func "$LINENO" "__secure_getenv" "ac_cv_func___secure_getenv"
if test "x$ac_cv_func___secure_getenv" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE___SECURE_GETENV 1
_ACEOF
fi
done
if test $ac_cv_func___secure_getenv = no; then
for ac_func in issetugid
do :
ac_fn_c_check_func "$LINENO" "issetugid" "ac_cv_func_issetugid"
if test "x$ac_cv_func_issetugid" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_ISSETUGID 1
_ACEOF
fi
done
fi
fi
GNULIB_SECURE_GETENV=1
$as_echo "#define GNULIB_TEST_SECURE_GETENV 1" >>confdefs.h
if test $ac_cv_func_setenv = no; then
HAVE_SETENV=0
else
@ -22301,6 +22496,11 @@ fi
:

View File

@ -21,7 +21,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inttypes limits-h lstat memchr memmem pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inttypes limits-h lstat memchr memmem mkstemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
AUTOMAKE_OPTIONS = 1.9.6 gnits
@ -1169,6 +1169,15 @@ EXTRA_libgnu_a_SOURCES += memrchr.c
## end gnulib module memrchr
## begin gnulib module mkstemp
EXTRA_DIST += mkstemp.c
EXTRA_libgnu_a_SOURCES += mkstemp.c
## end gnulib module mkstemp
## begin gnulib module msvc-inval
@ -1312,6 +1321,15 @@ EXTRA_DIST += save-cwd.h
## end gnulib module save-cwd
## begin gnulib module secure_getenv
EXTRA_DIST += secure_getenv.c
EXTRA_libgnu_a_SOURCES += secure_getenv.c
## end gnulib module secure_getenv
## begin gnulib module setenv
@ -2080,6 +2098,14 @@ EXTRA_DIST += sys_types.in.h
## end gnulib module sys_types
## begin gnulib module tempname
libgnu_a_SOURCES += tempname.c
EXTRA_DIST += tempname.h
## end gnulib module tempname
## begin gnulib module time
BUILT_SOURCES += time.h

View File

@ -36,7 +36,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inttypes limits-h lstat memchr memmem pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inttypes limits-h lstat memchr memmem mkstemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
@ -137,6 +137,7 @@ am__aclocal_m4_deps = $(top_srcdir)/import/m4/00gnulib.m4 \
$(top_srcdir)/import/m4/memmem.m4 \
$(top_srcdir)/import/m4/mempcpy.m4 \
$(top_srcdir)/import/m4/memrchr.m4 \
$(top_srcdir)/import/m4/mkstemp.m4 \
$(top_srcdir)/import/m4/mmap-anon.m4 \
$(top_srcdir)/import/m4/mode_t.m4 \
$(top_srcdir)/import/m4/msvc-inval.m4 \
@ -156,6 +157,7 @@ am__aclocal_m4_deps = $(top_srcdir)/import/m4/00gnulib.m4 \
$(top_srcdir)/import/m4/rewinddir.m4 \
$(top_srcdir)/import/m4/rmdir.m4 \
$(top_srcdir)/import/m4/save-cwd.m4 \
$(top_srcdir)/import/m4/secure_getenv.m4 \
$(top_srcdir)/import/m4/setenv.m4 \
$(top_srcdir)/import/m4/signal_h.m4 \
$(top_srcdir)/import/m4/ssize_t.m4 \
@ -175,6 +177,7 @@ am__aclocal_m4_deps = $(top_srcdir)/import/m4/00gnulib.m4 \
$(top_srcdir)/import/m4/sys_stat_h.m4 \
$(top_srcdir)/import/m4/sys_time_h.m4 \
$(top_srcdir)/import/m4/sys_types_h.m4 \
$(top_srcdir)/import/m4/tempname.m4 \
$(top_srcdir)/import/m4/time_h.m4 \
$(top_srcdir)/import/m4/unistd-safer.m4 \
$(top_srcdir)/import/m4/unistd_h.m4 \
@ -198,8 +201,9 @@ am_libgnu_a_OBJECTS = cloexec.$(OBJEXT) dirname-lgpl.$(OBJEXT) \
filenamecat-lgpl.$(OBJEXT) getprogname.$(OBJEXT) \
hard-locale.$(OBJEXT) localcharset.$(OBJEXT) malloca.$(OBJEXT) \
math.$(OBJEXT) openat-die.$(OBJEXT) save-cwd.$(OBJEXT) \
strnlen1.$(OBJEXT) unistd.$(OBJEXT) dup-safer.$(OBJEXT) \
fd-safer.$(OBJEXT) pipe-safer.$(OBJEXT) wctype-h.$(OBJEXT)
strnlen1.$(OBJEXT) tempname.$(OBJEXT) unistd.$(OBJEXT) \
dup-safer.$(OBJEXT) fd-safer.$(OBJEXT) pipe-safer.$(OBJEXT) \
wctype-h.$(OBJEXT)
libgnu_a_OBJECTS = $(am_libgnu_a_OBJECTS)
LTLIBRARIES = $(noinst_LTLIBRARIES)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
@ -1352,12 +1356,12 @@ EXTRA_DIST = m4/gnulib-cache.m4 alloca.c alloca.in.h assure.h \
lstat.c malloc.c malloca.h malloca.valgrind math.in.h \
mbrtowc.c mbsinit.c mbsrtowcs-impl.h mbsrtowcs-state.c \
mbsrtowcs.c memchr.c memchr.valgrind memmem.c str-two-way.h \
mempcpy.c memrchr.c msvc-inval.c msvc-inval.h msvc-nothrow.c \
msvc-nothrow.h open.c openat.c openat.h dirent-private.h \
opendir.c pathmax.h rawmemchr.c rawmemchr.valgrind \
dirent-private.h readdir.c readlink.c realloc.c rename.c \
dirent-private.h rewinddir.c rmdir.c same-inode.h save-cwd.h \
setenv.c signal.in.h \
mempcpy.c memrchr.c mkstemp.c msvc-inval.c msvc-inval.h \
msvc-nothrow.c msvc-nothrow.h open.c openat.c openat.h \
dirent-private.h opendir.c pathmax.h rawmemchr.c \
rawmemchr.valgrind dirent-private.h readdir.c readlink.c \
realloc.c rename.c dirent-private.h rewinddir.c rmdir.c \
same-inode.h save-cwd.h secure_getenv.c setenv.c signal.in.h \
$(top_srcdir)/import/extra/snippet/_Noreturn.h \
$(top_srcdir)/import/extra/snippet/arg-nonnull.h \
$(top_srcdir)/import/extra/snippet/c++defs.h \
@ -1366,9 +1370,10 @@ EXTRA_DIST = m4/gnulib-cache.m4 alloca.c alloca.in.h assure.h \
strchrnul.c strchrnul.valgrind strdup.c streq.h strerror.c \
strerror-override.c strerror-override.h string.in.h \
str-two-way.h strstr.c strtok_r.c sys_stat.in.h sys_time.in.h \
sys_types.in.h time.in.h unistd.in.h unistd--.h unistd-safer.h \
unsetenv.c $(top_srcdir)/import/extra/update-copyright \
verify.h wchar.in.h wctype.in.h
sys_types.in.h tempname.h time.in.h unistd.in.h unistd--.h \
unistd-safer.h unsetenv.c \
$(top_srcdir)/import/extra/update-copyright verify.h \
wchar.in.h wctype.in.h
# The BUILT_SOURCES created by this Makefile snippet are not used via #include
# statements but through direct file reference. Therefore this snippet must be
@ -1408,8 +1413,8 @@ libgnu_a_SOURCES = cloexec.c dirname-lgpl.c basename-lgpl.c \
stripslash.c exitfail.c fd-hook.c filenamecat-lgpl.c \
getprogname.h getprogname.c gettext.h hard-locale.c \
localcharset.h localcharset.c malloca.c math.c openat-die.c \
save-cwd.c strnlen1.h strnlen1.c unistd.c dup-safer.c \
fd-safer.c pipe-safer.c wctype-h.c
save-cwd.c strnlen1.h strnlen1.c tempname.c unistd.c \
dup-safer.c fd-safer.c pipe-safer.c wctype-h.c
libgnu_a_LIBADD = $(gl_LIBOBJS) @ALLOCA@
libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) @ALLOCA@
EXTRA_libgnu_a_SOURCES = alloca.c openat-proc.c canonicalize-lgpl.c \
@ -1419,11 +1424,12 @@ EXTRA_libgnu_a_SOURCES = alloca.c openat-proc.c canonicalize-lgpl.c \
fstatat.c getcwd.c getcwd-lgpl.c getdtablesize.c getlogin_r.c \
gettimeofday.c glob.c isnan.c isnand.c isnan.c isnanl.c \
lstat.c malloc.c mbrtowc.c mbsinit.c mbsrtowcs-state.c \
mbsrtowcs.c memchr.c memmem.c mempcpy.c memrchr.c msvc-inval.c \
msvc-nothrow.c open.c openat.c opendir.c rawmemchr.c readdir.c \
readlink.c realloc.c rename.c rewinddir.c rmdir.c setenv.c \
stat.c strchrnul.c strdup.c strerror.c strerror-override.c \
strstr.c strtok_r.c unsetenv.c
mbsrtowcs.c memchr.c memmem.c mempcpy.c memrchr.c mkstemp.c \
msvc-inval.c msvc-nothrow.c open.c openat.c opendir.c \
rawmemchr.c readdir.c readlink.c realloc.c rename.c \
rewinddir.c rmdir.c secure_getenv.c setenv.c stat.c \
strchrnul.c strdup.c strerror.c strerror-override.c strstr.c \
strtok_r.c unsetenv.c
# Use this preprocessor expression to decide whether #include_next works.
# Do not rely on a 'configure'-time test for this, since the expression
@ -1551,6 +1557,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memmem.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mempcpy.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memrchr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkstemp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msvc-inval.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msvc-nothrow.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/open.Po@am__quote@
@ -1567,6 +1574,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rewinddir.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rmdir.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/save-cwd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/secure_getenv.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setenv.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strchrnul.Po@am__quote@
@ -1577,6 +1585,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strnlen1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strstr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtok_r.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tempname.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unistd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unsetenv.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wctype-h.Po@am__quote@

View File

@ -27,7 +27,7 @@
# Specification in the form of a command-line invocation:
# gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inttypes limits-h lstat memchr memmem pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
# gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inttypes limits-h lstat memchr memmem mkstemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
@ -46,6 +46,7 @@ gl_MODULES([
lstat
memchr
memmem
mkstemp
pathmax
rawmemchr
readlink

View File

@ -118,6 +118,7 @@ AC_DEFUN([gl_EARLY],
# Code from module memmem-simple:
# Code from module mempcpy:
# Code from module memrchr:
# Code from module mkstemp:
# Code from module msvc-inval:
# Code from module msvc-nothrow:
# Code from module multiarch:
@ -137,6 +138,7 @@ AC_DEFUN([gl_EARLY],
# Code from module rmdir:
# Code from module same-inode:
# Code from module save-cwd:
# Code from module secure_getenv:
# Code from module setenv:
# Code from module signal-h:
# Code from module snippet/_Noreturn:
@ -163,6 +165,7 @@ AC_DEFUN([gl_EARLY],
# Code from module sys_stat:
# Code from module sys_time:
# Code from module sys_types:
# Code from module tempname:
# Code from module time:
# Code from module unistd:
# Code from module unistd-safer:
@ -421,6 +424,12 @@ AC_DEFUN([gl_INIT],
gl_PREREQ_MEMRCHR
fi
gl_STRING_MODULE_INDICATOR([memrchr])
gl_FUNC_MKSTEMP
if test $HAVE_MKSTEMP = 0 || test $REPLACE_MKSTEMP = 1; then
AC_LIBOBJ([mkstemp])
gl_PREREQ_MKSTEMP
fi
gl_STDLIB_MODULE_INDICATOR([mkstemp])
AC_REQUIRE([gl_MSVC_INVAL])
if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
AC_LIBOBJ([msvc-inval])
@ -487,6 +496,12 @@ AC_DEFUN([gl_INIT],
fi
gl_UNISTD_MODULE_INDICATOR([rmdir])
gl_SAVE_CWD
gl_FUNC_SECURE_GETENV
if test $HAVE_SECURE_GETENV = 0; then
AC_LIBOBJ([secure_getenv])
gl_PREREQ_SECURE_GETENV
fi
gl_STDLIB_MODULE_INDICATOR([secure_getenv])
gl_FUNC_SETENV
if test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1; then
AC_LIBOBJ([setenv])
@ -551,6 +566,7 @@ AC_DEFUN([gl_INIT],
AC_PROG_MKDIR_P
gl_SYS_TYPES_H
AC_PROG_MKDIR_P
gl_FUNC_GEN_TEMPNAME
gl_HEADER_TIME_H
gl_UNISTD_H
gl_UNISTD_SAFER
@ -797,6 +813,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/memmem.c
lib/mempcpy.c
lib/memrchr.c
lib/mkstemp.c
lib/msvc-inval.c
lib/msvc-inval.h
lib/msvc-nothrow.c
@ -823,6 +840,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/same-inode.h
lib/save-cwd.c
lib/save-cwd.h
lib/secure_getenv.c
lib/setenv.c
lib/signal.in.h
lib/stat.c
@ -848,6 +866,8 @@ AC_DEFUN([gl_FILE_LIST], [
lib/sys_stat.in.h
lib/sys_time.in.h
lib/sys_types.in.h
lib/tempname.c
lib/tempname.h
lib/time.in.h
lib/unistd--.h
lib/unistd-safer.h
@ -932,6 +952,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/memmem.m4
m4/mempcpy.m4
m4/memrchr.m4
m4/mkstemp.m4
m4/mmap-anon.m4
m4/mode_t.m4
m4/msvc-inval.m4
@ -951,6 +972,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/rewinddir.m4
m4/rmdir.m4
m4/save-cwd.m4
m4/secure_getenv.m4
m4/setenv.m4
m4/signal_h.m4
m4/ssize_t.m4
@ -970,6 +992,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/sys_stat_h.m4
m4/sys_time_h.m4
m4/sys_types_h.m4
m4/tempname.m4
m4/time_h.m4
m4/unistd-safer.m4
m4/unistd_h.m4

View File

@ -0,0 +1,82 @@
#serial 23
# Copyright (C) 2001, 2003-2007, 2009-2016 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# On some hosts (e.g., HP-UX 10.20, SunOS 4.1.4, Solaris 2.5.1), mkstemp has a
# silly limit that it can create no more than 26 files from a given template.
# Other systems lack mkstemp altogether.
# On OSF1/Tru64 V4.0F, the system-provided mkstemp function can create
# only 32 files per process.
# On some hosts, mkstemp creates files with mode 0666, which is a security
# problem and a violation of POSIX 2008.
# On systems like the above, arrange to use the replacement function.
AC_DEFUN([gl_FUNC_MKSTEMP],
[
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_CHECK_FUNCS_ONCE([mkstemp])
if test $ac_cv_func_mkstemp = yes; then
AC_CACHE_CHECK([for working mkstemp],
[gl_cv_func_working_mkstemp],
[
mkdir conftest.mkstemp
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[AC_INCLUDES_DEFAULT],
[[int result = 0;
int i;
off_t large = (off_t) 4294967295u;
if (large < 0)
large = 2147483647;
umask (0);
for (i = 0; i < 70; i++)
{
char templ[] = "conftest.mkstemp/coXXXXXX";
int (*mkstemp_function) (char *) = mkstemp;
int fd = mkstemp_function (templ);
if (fd < 0)
result |= 1;
else
{
struct stat st;
if (lseek (fd, large, SEEK_SET) != large)
result |= 2;
if (fstat (fd, &st) < 0)
result |= 4;
else if (st.st_mode & 0077)
result |= 8;
if (close (fd))
result |= 16;
}
}
return result;]])],
[gl_cv_func_working_mkstemp=yes],
[gl_cv_func_working_mkstemp=no],
[case "$host_os" in
# Guess yes on glibc systems.
*-gnu*) gl_cv_func_working_mkstemp="guessing yes" ;;
# If we don't know, assume the worst.
*) gl_cv_func_working_mkstemp="guessing no" ;;
esac
])
rm -rf conftest.mkstemp
])
case "$gl_cv_func_working_mkstemp" in
*yes) ;;
*)
REPLACE_MKSTEMP=1
;;
esac
else
HAVE_MKSTEMP=0
fi
])
# Prerequisites of lib/mkstemp.c.
AC_DEFUN([gl_PREREQ_MKSTEMP],
[
])

View File

@ -0,0 +1,26 @@
# Look up an environment variable more securely.
dnl Copyright 2013-2016 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_SECURE_GETENV],
[
dnl Persuade glibc <stdlib.h> to declare secure_getenv().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
AC_CHECK_FUNCS_ONCE([secure_getenv])
if test $ac_cv_func_secure_getenv = no; then
HAVE_SECURE_GETENV=0
fi
])
# Prerequisites of lib/secure_getenv.c.
AC_DEFUN([gl_PREREQ_SECURE_GETENV], [
AC_CHECK_FUNCS([__secure_getenv])
if test $ac_cv_func___secure_getenv = no; then
AC_CHECK_FUNCS([issetugid])
fi
AC_CHECK_FUNCS_ONCE([getuid geteuid getgid getegid])
])

View File

@ -0,0 +1,19 @@
#serial 5
# Copyright (C) 2006-2007, 2009-2016 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# glibc provides __gen_tempname as a wrapper for mk[ds]temp. Expose
# it as a public API, and provide it on systems that are lacking.
AC_DEFUN([gl_FUNC_GEN_TEMPNAME],
[
gl_PREREQ_TEMPNAME
])
# Prerequisites of lib/tempname.c.
AC_DEFUN([gl_PREREQ_TEMPNAME],
[
:
])

View File

@ -0,0 +1,50 @@
/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2016 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 "tempname.h"
# define __gen_tempname gen_tempname
# ifndef __GT_FILE
# define __GT_FILE GT_FILE
# endif
#endif
#include <stdio.h>
#ifndef __GT_FILE
# define __GT_FILE 0
#endif
/* Generate a unique temporary file name from XTEMPLATE.
The last six characters of XTEMPLATE must be "XXXXXX";
they are replaced with a string that makes the file name unique.
Then open the file and return a fd.
If you are creating temporary files which will later be removed,
consider using the clean-temp module, which avoids several pitfalls
of using mkstemp directly. */
int
mkstemp (char *xtemplate)
{
return __gen_tempname (xtemplate, 0, 0, __GT_FILE);
}

View File

@ -0,0 +1,54 @@
/* Look up an environment variable, returning NULL in insecure situations.
Copyright 2013-2016 Free Software Foundation, Inc.
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/>. */
#include <config.h>
#include <stdlib.h>
#if !HAVE___SECURE_GETENV
# if HAVE_ISSETUGID || (HAVE_GETUID && HAVE_GETEUID && HAVE_GETGID && HAVE_GETEGID)
# include <unistd.h>
# endif
#endif
char *
secure_getenv (char const *name)
{
#if HAVE___SECURE_GETENV /* glibc */
return __secure_getenv (name);
#elif HAVE_ISSETUGID /* OS X, FreeBSD, NetBSD, OpenBSD */
if (issetugid ())
return NULL;
return getenv (name);
#elif HAVE_GETUID && HAVE_GETEUID && HAVE_GETGID && HAVE_GETEGID /* other Unix */
if (geteuid () != getuid () || getegid () != getgid ())
return NULL;
return getenv (name);
#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* native Windows */
/* On native Windows, there is no such concept as setuid or setgid binaries.
- Programs launched as system services have high privileges, but they don't
inherit environment variables from a user.
- Programs launched by a user with "Run as Administrator" have high
privileges and use the environment variables, but the user has been asked
whether he agrees.
- Programs launched by a user without "Run as Administrator" cannot gain
high privileges, therefore there is no risk. */
return getenv (name);
#else
return NULL;
#endif
}

View File

@ -0,0 +1,324 @@
/* tempname.c - generate the name of a temporary file.
Copyright (C) 1991-2003, 2005-2007, 2009-2016 Free Software Foundation, Inc.
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/>. */
/* Extracted from glibc sysdeps/posix/tempname.c. See also tmpdir.c. */
#if !_LIBC
# include <config.h>
# include "tempname.h"
#endif
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
#ifndef __set_errno
# define __set_errno(Val) errno = (Val)
#endif
#include <stdio.h>
#ifndef P_tmpdir
# define P_tmpdir "/tmp"
#endif
#ifndef TMP_MAX
# define TMP_MAX 238328
#endif
#ifndef __GT_FILE
# define __GT_FILE 0
# define __GT_DIR 1
# define __GT_NOCREATE 2
#endif
#if !_LIBC && (GT_FILE != __GT_FILE || GT_DIR != __GT_DIR \
|| GT_NOCREATE != __GT_NOCREATE)
# error report this to bug-gnulib@gnu.org
#endif
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/time.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/stat.h>
#if _LIBC
# define struct_stat64 struct stat64
#else
# define struct_stat64 struct stat
# define __try_tempname try_tempname
# define __gen_tempname gen_tempname
# define __getpid getpid
# define __gettimeofday gettimeofday
# define __mkdir mkdir
# define __open open
# define __lxstat64(version, file, buf) lstat (file, buf)
# define __secure_getenv secure_getenv
#endif
#ifdef _LIBC
# include <hp-timing.h>
# if HP_TIMING_AVAIL
# define RANDOM_BITS(Var) \
if (__builtin_expect (value == UINT64_C (0), 0)) \
{ \
/* If this is the first time this function is used initialize \
the variable we accumulate the value in to some somewhat \
random value. If we'd not do this programs at startup time \
might have a reduced set of possible names, at least on slow \
machines. */ \
struct timeval tv; \
__gettimeofday (&tv, NULL); \
value = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; \
} \
HP_TIMING_NOW (Var)
# endif
#endif
/* Use the widest available unsigned type if uint64_t is not
available. The algorithm below extracts a number less than 62**6
(approximately 2**35.725) from uint64_t, so ancient hosts where
uintmax_t is only 32 bits lose about 3.725 bits of randomness,
which is better than not having mkstemp at all. */
#if !defined UINT64_MAX && !defined uint64_t
# define uint64_t uintmax_t
#endif
#if _LIBC
/* Return nonzero if DIR is an existent directory. */
static int
direxists (const char *dir)
{
struct_stat64 buf;
return __xstat64 (_STAT_VER, dir, &buf) == 0 && S_ISDIR (buf.st_mode);
}
/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is
non-null and exists, uses it; otherwise uses the first of $TMPDIR,
P_tmpdir, /tmp that exists. Copies into TMPL a template suitable
for use with mk[s]temp. Will fail (-1) if DIR is non-null and
doesn't exist, none of the searched dirs exists, or there's not
enough space in TMPL. */
int
__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
int try_tmpdir)
{
const char *d;
size_t dlen, plen;
if (!pfx || !pfx[0])
{
pfx = "file";
plen = 4;
}
else
{
plen = strlen (pfx);
if (plen > 5)
plen = 5;
}
if (try_tmpdir)
{
d = __secure_getenv ("TMPDIR");
if (d != NULL && direxists (d))
dir = d;
else if (dir != NULL && direxists (dir))
/* nothing */ ;
else
dir = NULL;
}
if (dir == NULL)
{
if (direxists (P_tmpdir))
dir = P_tmpdir;
else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
dir = "/tmp";
else
{
__set_errno (ENOENT);
return -1;
}
}
dlen = strlen (dir);
while (dlen > 1 && dir[dlen - 1] == '/')
dlen--; /* remove trailing slashes */
/* check we have room for "${dir}/${pfx}XXXXXX\0" */
if (tmpl_len < dlen + 1 + plen + 6 + 1)
{
__set_errno (EINVAL);
return -1;
}
sprintf (tmpl, "%.*s/%.*sXXXXXX", (int) dlen, dir, (int) plen, pfx);
return 0;
}
#endif /* _LIBC */
/* These are the characters used in temporary file names. */
static const char letters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
int
__try_tempname (char *tmpl, int suffixlen, void *args,
int (*tryfunc) (char *, void *))
{
int len;
char *XXXXXX;
static uint64_t value;
uint64_t random_time_bits;
unsigned int count;
int fd = -1;
int save_errno = errno;
/* A lower bound on the number of temporary files to attempt to
generate. The maximum total number of temporary file names that
can exist for a given template is 62**6. It should never be
necessary to try all of these combinations. Instead if a reasonable
number of names is tried (we define reasonable as 62**3) fail to
give the system administrator the chance to remove the problems. */
#define ATTEMPTS_MIN (62 * 62 * 62)
/* The number of times to attempt to generate a temporary file. To
conform to POSIX, this must be no smaller than TMP_MAX. */
#if ATTEMPTS_MIN < TMP_MAX
unsigned int attempts = TMP_MAX;
#else
unsigned int attempts = ATTEMPTS_MIN;
#endif
len = strlen (tmpl);
if (len < 6 + suffixlen || memcmp (&tmpl[len - 6 - suffixlen], "XXXXXX", 6))
{
__set_errno (EINVAL);
return -1;
}
/* This is where the Xs start. */
XXXXXX = &tmpl[len - 6 - suffixlen];
/* Get some more or less random data. */
#ifdef RANDOM_BITS
RANDOM_BITS (random_time_bits);
#else
{
struct timeval tv;
__gettimeofday (&tv, NULL);
random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec;
}
#endif
value += random_time_bits ^ __getpid ();
for (count = 0; count < attempts; value += 7777, ++count)
{
uint64_t v = value;
/* Fill in the random bits. */
XXXXXX[0] = letters[v % 62];
v /= 62;
XXXXXX[1] = letters[v % 62];
v /= 62;
XXXXXX[2] = letters[v % 62];
v /= 62;
XXXXXX[3] = letters[v % 62];
v /= 62;
XXXXXX[4] = letters[v % 62];
v /= 62;
XXXXXX[5] = letters[v % 62];
fd = tryfunc (tmpl, args);
if (fd >= 0)
{
__set_errno (save_errno);
return fd;
}
else if (errno != EEXIST)
return -1;
}
/* We got out of the loop because we ran out of combinations to try. */
__set_errno (EEXIST);
return -1;
}
static int
try_file (char *tmpl, void *flags)
{
int *openflags = flags;
return __open (tmpl,
(*openflags & ~O_ACCMODE)
| O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
}
static int
try_dir (char *tmpl, void *flags _GL_UNUSED)
{
return __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
}
static int
try_nocreate (char *tmpl, void *flags _GL_UNUSED)
{
struct_stat64 st;
if (__lxstat64 (_STAT_VER, tmpl, &st) == 0)
__set_errno (EEXIST);
return errno == ENOENT ? 0 : -1;
}
/* Generate a temporary file name based on TMPL. TMPL must match the
rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
The name constructed does not exist at the time of the call to
__gen_tempname. TMPL is overwritten with the result.
KIND may be one of:
__GT_NOCREATE: simply verify that the name does not exist
at the time of the call.
__GT_FILE: create the file using open(O_CREAT|O_EXCL)
and return a read-write fd. The file is mode 0600.
__GT_DIR: create a directory, which will be mode 0700.
We use a clever algorithm to get hard-to-predict names. */
int
__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
{
int (*tryfunc) (char *, void *);
switch (kind)
{
case __GT_FILE:
tryfunc = try_file;
break;
case __GT_DIR:
tryfunc = try_dir;
break;
case __GT_NOCREATE:
tryfunc = try_nocreate;
break;
default:
assert (! "invalid KIND in __gen_tempname");
abort ();
}
return __try_tempname (tmpl, suffixlen, &flags, tryfunc);
}

View File

@ -0,0 +1,65 @@
/* Create a temporary file or directory.
Copyright (C) 2006, 2009-2016 Free Software Foundation, Inc.
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/>. */
/* header written by Eric Blake */
#ifndef GL_TEMPNAME_H
# define GL_TEMPNAME_H
# include <stdio.h>
# ifdef __GT_FILE
# define GT_FILE __GT_FILE
# define GT_DIR __GT_DIR
# define GT_NOCREATE __GT_NOCREATE
# else
# define GT_FILE 0
# define GT_DIR 1
# define GT_NOCREATE 2
# endif
#ifdef __cplusplus
extern "C" {
#endif
/* Generate a temporary file name based on TMPL. TMPL must match the
rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
The name constructed does not exist at the time of the call to
gen_tempname. TMPL is overwritten with the result.
KIND may be one of:
GT_NOCREATE: simply verify that the name does not exist
at the time of the call.
GT_FILE: create a large file using open(O_CREAT|O_EXCL)
and return a read-write fd. The file is mode 0600.
GT_DIR: create a directory, which will be mode 0700.
We use a clever algorithm to get hard-to-predict names. */
extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
/* Similar to gen_tempname, but TRYFUNC is called for each temporary
name to try. If TRYFUNC returns a non-negative number, TRY_GEN_TEMPNAME
returns with this value. Otherwise, if errno is set to EEXIST, another
name is tried, or else TRY_GEN_TEMPNAME returns -1. */
extern int try_tempname (char *tmpl, int suffixlen, void *args,
int (*tryfunc) (char *, void *));
#ifdef __cplusplus
}
#endif
#endif /* GL_TEMPNAME_H */

View File

@ -44,6 +44,7 @@ IMPORTED_GNULIB_MODULES="\
limits-h \
memchr \
memmem \
mkstemp \
pathmax \
rawmemchr \
readlink \