Imported Upstream version 2.0

This commit is contained in:
Jan Wagner 2014-07-11 21:01:00 +02:00
parent c89ccc3c74
commit 0841b5c7c7
165 changed files with 25440 additions and 4442 deletions

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 --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext mountlist regex setenv strsep timegm unsetenv vasprintf vsnprintf
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strsep timegm unsetenv vasprintf vsnprintf
AUTOMAKE_OPTIONS = 1.9.6 gnits subdir-objects
@ -402,6 +402,14 @@ EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath
## end gnulib module havelib
## begin gnulib module idpriv-droptemp
libgnu_a_SOURCES += idpriv-droptemp.c
EXTRA_DIST += idpriv.h
## end gnulib module idpriv-droptemp
## begin gnulib module inet_ntop
@ -1536,6 +1544,15 @@ EXTRA_DIST += stdlib.in.h
## end gnulib module stdlib
## begin gnulib module strcase
EXTRA_DIST += strcasecmp.c strncasecmp.c
EXTRA_libgnu_a_SOURCES += strcasecmp.c strncasecmp.c
## end gnulib module strcase
## begin gnulib module streq
@ -1661,6 +1678,37 @@ EXTRA_DIST += string.in.h
## end gnulib module string
## begin gnulib module strings
BUILT_SOURCES += strings.h
# We need the following in order to create <strings.h> when the system
# doesn't have one that works with the given compiler.
strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''HAVE_STRINGS_H''@|$(HAVE_STRINGS_H)|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
-e 's|@''GNULIB_FFS''@|$(GNULIB_FFS)|g' \
-e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \
-e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
-e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/strings.in.h; \
} > $@-t && \
mv $@-t $@
MOSTLYCLEANFILES += strings.h strings.h-t
EXTRA_DIST += strings.in.h
## end gnulib module strings
## begin gnulib module strndup

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 --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext mountlist regex setenv strsep timegm unsetenv vasprintf vsnprintf
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strsep timegm unsetenv vasprintf vsnprintf
@ -104,6 +104,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/gnulib-common.m4 \
$(top_srcdir)/gl/m4/gnulib-comp.m4 \
$(top_srcdir)/gl/m4/hostent.m4 $(top_srcdir)/gl/m4/iconv.m4 \
$(top_srcdir)/gl/m4/idpriv.m4 \
$(top_srcdir)/gl/m4/include_next.m4 \
$(top_srcdir)/gl/m4/inet_ntop.m4 \
$(top_srcdir)/gl/m4/intlmacosx.m4 \
@ -153,11 +154,12 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/stdalign.m4 $(top_srcdir)/gl/m4/stdbool.m4 \
$(top_srcdir)/gl/m4/stddef_h.m4 $(top_srcdir)/gl/m4/stdint.m4 \
$(top_srcdir)/gl/m4/stdint_h.m4 $(top_srcdir)/gl/m4/stdio_h.m4 \
$(top_srcdir)/gl/m4/stdlib_h.m4 \
$(top_srcdir)/gl/m4/stdlib_h.m4 $(top_srcdir)/gl/m4/strcase.m4 \
$(top_srcdir)/gl/m4/strerror.m4 \
$(top_srcdir)/gl/m4/string_h.m4 $(top_srcdir)/gl/m4/strndup.m4 \
$(top_srcdir)/gl/m4/strnlen.m4 $(top_srcdir)/gl/m4/strsep.m4 \
$(top_srcdir)/gl/m4/strstr.m4 \
$(top_srcdir)/gl/m4/string_h.m4 \
$(top_srcdir)/gl/m4/strings_h.m4 \
$(top_srcdir)/gl/m4/strndup.m4 $(top_srcdir)/gl/m4/strnlen.m4 \
$(top_srcdir)/gl/m4/strsep.m4 $(top_srcdir)/gl/m4/strstr.m4 \
$(top_srcdir)/gl/m4/sys_socket_h.m4 \
$(top_srcdir)/gl/m4/sys_types_h.m4 \
$(top_srcdir)/gl/m4/sys_uio_h.m4 \
@ -172,7 +174,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/wcrtomb.m4 $(top_srcdir)/gl/m4/wctype_h.m4 \
$(top_srcdir)/gl/m4/wint_t.m4 $(top_srcdir)/gl/m4/xalloc.m4 \
$(top_srcdir)/gl/m4/xsize.m4 $(top_srcdir)/gl/m4/xstrndup.m4 \
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.in
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/build-aux/mkinstalldirs
@ -187,9 +189,9 @@ am_libgnu_a_OBJECTS = base64.$(OBJEXT) sha1.$(OBJEXT) \
dirname.$(OBJEXT) basename.$(OBJEXT) dirname-lgpl.$(OBJEXT) \
basename-lgpl.$(OBJEXT) stripslash.$(OBJEXT) \
exitfail.$(OBJEXT) fd-hook.$(OBJEXT) full-read.$(OBJEXT) \
localcharset.$(OBJEXT) glthread/lock.$(OBJEXT) \
malloca.$(OBJEXT) math.$(OBJEXT) safe-read.$(OBJEXT) \
sockets.$(OBJEXT) sys_socket.$(OBJEXT) \
idpriv-droptemp.$(OBJEXT) localcharset.$(OBJEXT) \
glthread/lock.$(OBJEXT) malloca.$(OBJEXT) math.$(OBJEXT) \
safe-read.$(OBJEXT) sockets.$(OBJEXT) sys_socket.$(OBJEXT) \
glthread/threadlib.$(OBJEXT) unistd.$(OBJEXT) \
wctype-h.$(OBJEXT) xmalloc.$(OBJEXT) xalloc-die.$(OBJEXT) \
xsize.$(OBJEXT) xstrndup.$(OBJEXT)
@ -369,6 +371,7 @@ GNULIB_FCLOSE = @GNULIB_FCLOSE@
GNULIB_FDATASYNC = @GNULIB_FDATASYNC@
GNULIB_FDOPEN = @GNULIB_FDOPEN@
GNULIB_FFLUSH = @GNULIB_FFLUSH@
GNULIB_FFS = @GNULIB_FFS@
GNULIB_FFSL = @GNULIB_FFSL@
GNULIB_FFSLL = @GNULIB_FFSLL@
GNULIB_FGETC = @GNULIB_FGETC@
@ -734,6 +737,7 @@ HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@
HAVE_DECL_SQRTL = @HAVE_DECL_SQRTL@
HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
HAVE_DECL_STRNCASECMP = @HAVE_DECL_STRNCASECMP@
HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
@ -763,6 +767,7 @@ HAVE_FCHDIR = @HAVE_FCHDIR@
HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
HAVE_FDATASYNC = @HAVE_FDATASYNC@
HAVE_FEATURES_H = @HAVE_FEATURES_H@
HAVE_FFS = @HAVE_FFS@
HAVE_FFSL = @HAVE_FFSL@
HAVE_FFSLL = @HAVE_FFSLL@
HAVE_FMA = @HAVE_FMA@
@ -874,8 +879,10 @@ HAVE_SQRTL = @HAVE_SQRTL@
HAVE_STDINT_H = @HAVE_STDINT_H@
HAVE_STPCPY = @HAVE_STPCPY@
HAVE_STPNCPY = @HAVE_STPNCPY@
HAVE_STRCASECMP = @HAVE_STRCASECMP@
HAVE_STRCASESTR = @HAVE_STRCASESTR@
HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
HAVE_STRINGS_H = @HAVE_STRINGS_H@
HAVE_STRPBRK = @HAVE_STRPBRK@
HAVE_STRPTIME = @HAVE_STRPTIME@
HAVE_STRSEP = @HAVE_STRSEP@
@ -966,7 +973,6 @@ LD = @LD@
LDAPINCLUDE = @LDAPINCLUDE@
LDAPLIBS = @LDAPLIBS@
LDFLAGS = @LDFLAGS@
LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
LIBICONV = @LIBICONV@
@ -992,6 +998,7 @@ LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
LTLIBOBJS = @LTLIBOBJS@
LTLIBPTH = @LTLIBPTH@
LTLIBTHREAD = @LTLIBTHREAD@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MATHLIBS = @MATHLIBS@
@ -1017,6 +1024,7 @@ NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
NEXT_AS_FIRST_DIRECTIVE_STRINGS_H = @NEXT_AS_FIRST_DIRECTIVE_STRINGS_H@
NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H@
NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H@
@ -1037,6 +1045,7 @@ NEXT_STDDEF_H = @NEXT_STDDEF_H@
NEXT_STDINT_H = @NEXT_STDINT_H@
NEXT_STDIO_H = @NEXT_STDIO_H@
NEXT_STDLIB_H = @NEXT_STDLIB_H@
NEXT_STRINGS_H = @NEXT_STRINGS_H@
NEXT_STRING_H = @NEXT_STRING_H@
NEXT_SYS_SOCKET_H = @NEXT_SYS_SOCKET_H@
NEXT_SYS_TYPES_H = @NEXT_SYS_TYPES_H@
@ -1096,7 +1105,6 @@ PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
PST3CFLAGS = @PST3CFLAGS@
PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
PYTHON = @PYTHON@
RADIUSLIBS = @RADIUSLIBS@
RANLIB = @RANLIB@
RELEASE = @RELEASE@
@ -1288,7 +1296,6 @@ SCRIPT_TEST = @SCRIPT_TEST@
SED = @SED@
SERVENT_LIB = @SERVENT_LIB@
SET_MAKE = @SET_MAKE@
SH = @SH@
SHELL = @SHELL@
SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
@ -1312,6 +1319,7 @@ WARRANTY = @WARRANTY@
WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@
WINT_T_SUFFIX = @WINT_T_SUFFIX@
WTSAPI32LIBS = @WTSAPI32LIBS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
@ -1399,30 +1407,31 @@ EXTRA_DIST = m4/gnulib-cache.m4 alloca.in.h arpa_inet.in.h btowc.c \
gai_strerror.c getaddrinfo.c gethostname.c w32sock.h \
getloadavg.c getopt.c getopt.in.h getopt1.c getopt_int.h \
$(top_srcdir)/build-aux/config.rpath \
$(top_srcdir)/build-aux/config.rpath inet_ntop.c intprops.h \
langinfo.in.h config.charset ref-add.sin ref-del.sin \
locale.in.h localeconv.c malloc.c malloc.c malloca.h \
malloca.valgrind math.in.h mbrtowc.c mbsinit.c mbtowc-impl.h \
mbtowc.c memchr.c memchr.valgrind mktime-internal.h mktime.c \
mktime-internal.h mktime.c mountlist.c mountlist.h \
msvc-inval.c msvc-inval.h msvc-nothrow.c msvc-nothrow.h \
netdb.in.h netinet_in.in.h nl_langinfo.c read.c regcomp.c \
regex.c regex.h regex_internal.c regex_internal.h regexec.c \
safe-read.h setenv.c \
$(top_srcdir)/build-aux/snippet/_Noreturn.h \
$(top_srcdir)/build-aux/config.rpath idpriv.h inet_ntop.c \
intprops.h langinfo.in.h config.charset ref-add.sin \
ref-del.sin locale.in.h localeconv.c malloc.c malloc.c \
malloca.h malloca.valgrind math.in.h mbrtowc.c mbsinit.c \
mbtowc-impl.h mbtowc.c memchr.c memchr.valgrind \
mktime-internal.h mktime.c mktime-internal.h mktime.c \
mountlist.c mountlist.h msvc-inval.c msvc-inval.h \
msvc-nothrow.c msvc-nothrow.h netdb.in.h netinet_in.in.h \
nl_langinfo.c read.c regcomp.c regex.c regex.h \
regex_internal.c regex_internal.h regexec.c safe-read.h \
setenv.c $(top_srcdir)/build-aux/snippet/_Noreturn.h \
$(top_srcdir)/build-aux/snippet/arg-nonnull.h \
$(top_srcdir)/build-aux/snippet/c++defs.h \
$(top_srcdir)/build-aux/snippet/warn-on-use.h snprintf.c \
w32sock.h stdalign.in.h stdbool.in.h stddef.in.h stdint.in.h \
stdio.in.h stdlib.in.h streq.h strerror.c strerror-override.c \
strerror-override.h string.in.h strndup.c strnlen.c strsep.c \
str-two-way.h strstr.c sys_socket.in.h sys_types.in.h \
sys_uio.in.h $(top_srcdir)/build-aux/config.rpath time.in.h \
time_r.c mktime-internal.h timegm.c unistd.in.h unsetenv.c \
asnprintf.c float+.h printf-args.c printf-args.h \
printf-parse.c printf-parse.h vasnprintf.c vasnprintf.h \
asprintf.c vasprintf.c verify.h vsnprintf.c wchar.in.h \
wcrtomb.c wctype.in.h xalloc.h xalloc-oversized.h
stdio.in.h stdlib.in.h strcasecmp.c strncasecmp.c streq.h \
strerror.c strerror-override.c strerror-override.h string.in.h \
strings.in.h strndup.c strnlen.c strsep.c str-two-way.h \
strstr.c sys_socket.in.h sys_types.in.h sys_uio.in.h \
$(top_srcdir)/build-aux/config.rpath time.in.h time_r.c \
mktime-internal.h timegm.c unistd.in.h unsetenv.c asnprintf.c \
float+.h printf-args.c printf-args.h printf-parse.c \
printf-parse.h vasnprintf.c vasnprintf.h asprintf.c \
vasprintf.c verify.h vsnprintf.c wchar.in.h wcrtomb.c \
wctype.in.h xalloc.h xalloc-oversized.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
@ -1437,8 +1446,8 @@ BUILT_SOURCES = $(ALLOCA_H) arpa/inet.h configmake.h $(ERRNO_H) \
$(FLOAT_H) $(GETOPT_H) langinfo.h locale.h math.h netdb.h \
$(NETINET_IN_H) arg-nonnull.h c++defs.h warn-on-use.h \
$(STDALIGN_H) $(STDBOOL_H) $(STDDEF_H) $(STDINT_H) stdio.h \
stdlib.h string.h sys/socket.h sys/types.h sys/uio.h time.h \
unistd.h wchar.h wctype.h
stdlib.h string.h strings.h sys/socket.h sys/types.h sys/uio.h \
time.h unistd.h wchar.h wctype.h
SUFFIXES = .sed .sin
MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t arpa/inet.h \
arpa/inet.h-t errno.h errno.h-t float.h float.h-t getopt.h \
@ -1448,9 +1457,9 @@ MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t arpa/inet.h \
warn-on-use.h warn-on-use.h-t stdalign.h stdalign.h-t \
stdbool.h stdbool.h-t stddef.h stddef.h-t stdint.h stdint.h-t \
stdio.h stdio.h-t stdlib.h stdlib.h-t string.h string.h-t \
sys/socket.h sys/socket.h-t sys/types.h sys/types.h-t \
sys/uio.h sys/uio.h-t time.h time.h-t unistd.h unistd.h-t \
wchar.h wchar.h-t wctype.h wctype.h-t
strings.h strings.h-t sys/socket.h sys/socket.h-t sys/types.h \
sys/types.h-t sys/uio.h sys/uio.h-t time.h time.h-t unistd.h \
unistd.h-t wchar.h wchar.h-t wctype.h wctype.h-t
MOSTLYCLEANDIRS = arpa netinet sys sys
CLEANFILES = configmake.h configmake.h-t charset.alias ref-add.sed \
ref-del.sed
@ -1460,11 +1469,11 @@ AM_CPPFLAGS =
AM_CFLAGS =
libgnu_a_SOURCES = base64.h base64.c sha1.c dirname.c basename.c \
dirname-lgpl.c basename-lgpl.c stripslash.c exitfail.c \
fd-hook.c full-read.h full-read.c gettext.h localcharset.h \
localcharset.c glthread/lock.h glthread/lock.c malloca.c \
math.c safe-read.c size_max.h sockets.h sockets.c sys_socket.c \
glthread/threadlib.c unistd.c wctype-h.c xmalloc.c \
xalloc-die.c xsize.h xsize.c xstrndup.h xstrndup.c
fd-hook.c full-read.h full-read.c gettext.h idpriv-droptemp.c \
localcharset.h localcharset.c glthread/lock.h glthread/lock.c \
malloca.c math.c safe-read.c size_max.h sockets.h sockets.c \
sys_socket.c glthread/threadlib.c unistd.c wctype-h.c \
xmalloc.c xalloc-die.c xsize.h xsize.c xstrndup.h xstrndup.c
libgnu_a_LIBADD = $(gl_LIBOBJS)
libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
EXTRA_libgnu_a_SOURCES = btowc.c stripslash.c error.c float.c itold.c \
@ -1473,11 +1482,11 @@ EXTRA_libgnu_a_SOURCES = btowc.c stripslash.c error.c float.c itold.c \
inet_ntop.c localeconv.c malloc.c malloc.c mbrtowc.c mbsinit.c \
mbtowc.c memchr.c mktime.c mktime.c mountlist.c msvc-inval.c \
msvc-nothrow.c nl_langinfo.c read.c regcomp.c regex.c \
regex_internal.c regexec.c setenv.c snprintf.c strerror.c \
strerror-override.c strndup.c strnlen.c strsep.c strstr.c \
time_r.c timegm.c unsetenv.c asnprintf.c printf-args.c \
printf-parse.c vasnprintf.c asprintf.c vasprintf.c vsnprintf.c \
wcrtomb.c
regex_internal.c regexec.c setenv.c snprintf.c strcasecmp.c \
strncasecmp.c strerror.c strerror-override.c strndup.c \
strnlen.c strsep.c strstr.c time_r.c timegm.c unsetenv.c \
asnprintf.c printf-args.c printf-parse.c vasnprintf.c \
asprintf.c vasprintf.c vsnprintf.c wcrtomb.c
charset_alias = $(DESTDIR)$(libdir)/charset.alias
charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
@ -1493,7 +1502,7 @@ all: $(BUILT_SOURCES)
.SUFFIXES:
.SUFFIXES: .sed .sin .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
@ -1518,9 +1527,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
@ -1581,6 +1590,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getloadavg.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idpriv-droptemp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inet_ntop.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/itold.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localcharset.Po@am__quote@
@ -1609,9 +1619,11 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snprintf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sockets.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strcasecmp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror-override.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stripslash.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strncasecmp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strndup.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strnlen.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strsep.Po@am__quote@
@ -2952,6 +2964,28 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
} > $@-t && \
mv $@-t $@
# We need the following in order to create <strings.h> when the system
# doesn't have one that works with the given compiler.
strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''HAVE_STRINGS_H''@|$(HAVE_STRINGS_H)|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
-e 's|@''GNULIB_FFS''@|$(GNULIB_FFS)|g' \
-e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \
-e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
-e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/strings.in.h; \
} > $@-t && \
mv $@-t $@
# We need the following in order to create <sys/socket.h> when the system
# doesn't have one that works with the given compiler.
sys/socket.h: sys_socket.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)

204
gl/idpriv-droptemp.c Normal file
View file

@ -0,0 +1,204 @@
/* Dropping uid/gid privileges of the current process temporarily.
Copyright (C) 2009-2013 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 "idpriv.h"
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
/* The privileged uid and gid that the process had earlier. */
#if HAVE_GETUID
static int saved_uid = -1;
#endif
#if HAVE_GETGID
static int saved_gid = -1;
#endif
int
idpriv_temp_drop (void)
{
#if HAVE_GETEUID && HAVE_GETEGID && (HAVE_SETRESUID || HAVE_SETREUID) && (HAVE_SETRESGID || HAVE_SETREGID)
int uid = getuid ();
int gid = getgid ();
/* Find out about the privileged uid and gid at the first call. */
if (saved_uid == -1)
saved_uid = geteuid ();
if (saved_gid == -1)
saved_gid = getegid ();
/* Drop the gid privilege first, because in some cases the gid privilege
cannot be dropped after the uid privilege has been dropped. */
/* This is for executables that have the setgid bit set. */
# if HAVE_SETRESGID /* glibc, FreeBSD, OpenBSD, HP-UX */
if (setresgid (-1, gid, saved_gid) < 0)
return -1;
# else /* Mac OS X, NetBSD, AIX, IRIX, Solaris >= 2.5, OSF/1, Cygwin */
if (setregid (-1, gid) < 0)
return -1;
# endif
/* This is for executables that have the setuid bit set. */
# if HAVE_SETRESUID /* glibc, FreeBSD, OpenBSD, HP-UX */
/* See <http://www.usenix.org/events/sec02/full_papers/chen/chen.pdf>
figure 14. */
if (setresuid (-1, uid, saved_uid) < 0)
return -1;
# else /* Mac OS X, NetBSD, AIX, IRIX, Solaris >= 2.5, OSF/1, Cygwin */
if (setreuid (-1, uid) < 0)
return -1;
# endif
/* Verify that the privileges have really been dropped.
This verification is here for security reasons. Doesn't matter if it
takes a couple of system calls.
When the verification fails, it indicates that we need to use different
API in the code above. Therefore 'abort ()', not 'return -1'. */
# if HAVE_GETRESUID /* glibc, FreeBSD, OpenBSD, HP-UX */
{
uid_t real;
uid_t effective;
uid_t saved;
if (getresuid (&real, &effective, &saved) < 0
|| real != uid
|| effective != uid
|| saved != saved_uid)
abort ();
}
# else
# if HAVE_GETEUID
if (geteuid () != uid)
abort ();
# endif
if (getuid () != uid)
abort ();
# endif
# if HAVE_GETRESGID /* glibc, FreeBSD, OpenBSD, HP-UX */
{
uid_t real;
uid_t effective;
uid_t saved;
if (getresgid (&real, &effective, &saved) < 0
|| real != gid
|| effective != gid
|| saved != saved_gid)
abort ();
}
# else
# if HAVE_GETEGID
if (getegid () != gid)
abort ();
# endif
if (getgid () != gid)
abort ();
# endif
return 0;
#else
errno = ENOSYS;
return -1;
#endif
}
int
idpriv_temp_restore (void)
{
#if HAVE_GETEUID && HAVE_GETEGID && (HAVE_SETRESUID || HAVE_SETREUID) && (HAVE_SETRESGID || HAVE_SETREGID)
int uid = getuid ();
int gid = getgid ();
if (saved_uid == -1 || saved_gid == -1)
/* Caller error: idpriv_temp_drop was never invoked. */
abort ();
/* Acquire the gid privilege last, because in some cases the gid privilege
cannot be acquired before the uid privilege has been acquired. */
/* This is for executables that have the setuid bit set. */
# if HAVE_SETRESUID /* glibc, FreeBSD, OpenBSD, HP-UX */
/* See <http://www.usenix.org/events/sec02/full_papers/chen/chen.pdf>
figure 14. */
if (setresuid (-1, saved_uid, -1) < 0)
return -1;
# else /* Mac OS X, NetBSD, AIX, IRIX, Solaris >= 2.5, OSF/1, Cygwin */
if (setreuid (-1, saved_uid) < 0)
return -1;
# endif
/* This is for executables that have the setgid bit set. */
# if HAVE_SETRESGID /* glibc, FreeBSD, OpenBSD, HP-UX */
if (setresgid (-1, saved_gid, -1) < 0)
return -1;
# else /* Mac OS X, NetBSD, AIX, IRIX, Solaris >= 2.5, OSF/1, Cygwin */
if (setregid (-1, saved_gid) < 0)
return -1;
# endif
/* Verify that the privileges have really been acquired.
This verification is here for security reasons. Doesn't matter if it
takes a couple of system calls.
When the verification fails, it indicates that we need to use different
API in the code above. Therefore 'abort ()', not 'return -1'. */
# if HAVE_GETRESUID /* glibc, FreeBSD, OpenBSD, HP-UX */
{
uid_t real;
uid_t effective;
uid_t saved;
if (getresuid (&real, &effective, &saved) < 0
|| real != uid
|| effective != saved_uid
|| saved != saved_uid)
abort ();
}
# else
# if HAVE_GETEUID
if (geteuid () != saved_uid)
abort ();
# endif
if (getuid () != uid)
abort ();
# endif
# if HAVE_GETRESGID /* glibc, FreeBSD, OpenBSD, HP-UX */
{
uid_t real;
uid_t effective;
uid_t saved;
if (getresgid (&real, &effective, &saved) < 0
|| real != gid
|| effective != saved_gid
|| saved != saved_gid)
abort ();
}
# else
# if HAVE_GETEGID
if (getegid () != saved_gid)
abort ();
# endif
if (getgid () != gid)
abort ();
# endif
return 0;
#else
errno = ENOSYS;
return -1;
#endif
}

116
gl/idpriv.h Normal file
View file

@ -0,0 +1,116 @@
/* Dropping uid/gid privileges of the current process.
Copyright (C) 2009-2013 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/>. */
#ifndef _IDPRIV_H
#define _IDPRIV_H
#ifdef __cplusplus
extern "C" {
#endif
/* This module allows programs which are installed with setuid or setgid bit
(and which therefore initially run with an effective user id or group id
different from the one of the current user) to drop their uid or gid
privilege, either permanently or temporarily.
It is absolutely necessary to minimize the amount of code that is running
with escalated privileges (e.g. with effective uid = root). The reason is
that any bug or exploit in a part of a program that is running with
escalated privileges is a security vulnerability that - upon discovery -
puts the users in danger and requires immediate fixing. Then consider that
there's a bug every 10 or 20 lines of code on average...
For programs that temporarily drop privileges but have the ability to
restore them later, there are additionally the dangers that
- Any bug in the non-privileged part of the program may be used to
create invalid data structures that will trigger security
vulnerabilities in the privileged part of the program.
- Code execution exploits in the non-privileged part of the program may
be used to invoke the function that restores high privileges and then
execute additional arbitrary code.
1) The usual, and reasonably safe, way to minimize the amount of code
running with privileges is to create a separate executable, with setuid
or setgid bit, that contains only code for the tasks that require
privileges (and,of course, strict checking of the arguments, so that the
program cannot be abused). The main program is installed without setuid
or setgid bit.
2) A less safe way is to do some privileged tasks at the beginning of the
program's run, and drop privileges permanently as soon as possible.
Note: There may still be security issues if the privileged task puts
sensitive data into the process memory or opens communication channels
to restricted facilities.
3) The most unsafe way is to drop privileges temporarily for most of the
main program but to re-enable them for the duration of privileged tasks.
As explained above, this approach has uncontrollable dangers for
security.
This approach is normally not usable in multithreaded programs, because
you cannot know what kind of system calls the other threads could be
doing during the time the privileges are enabled.
With approach 1, you don't need gnulib modules.
With approach 2, you need the gnulib module 'idpriv-drop'.
With approach 3, you need the gnulib module 'idpriv-droptemp'. But really,
you should better stay away from this approach.
*/
/* For more in-depth discussion of these topics, see the papers/articles
* Hao Chen, David Wagner, Drew Dean: Setuid Demystified
<http://www.usenix.org/events/sec02/full_papers/chen/chen.pdf>
* Dan Tsafrir, Dilma da Silva, David Wagner: The Murky Issue of Changing
Process Identity: Revising "Setuid Demystified"
<http://www.eecs.berkeley.edu/~daw/papers/setuid-login08b.pdf>
<http://code.google.com/p/change-process-identity/>
* Dhruv Mohindra: Observe correct revocation order while relinquishing
privileges
<https://www.securecoding.cert.org/confluence/display/seccode/POS36-C.+Observe+correct+revocation+order+while+relinquishing+privileges>
*/
/* For approach 2. */
/* Drop the uid and gid privileges of the current process.
Return 0 if successful, or -1 with errno set upon failure. The recommended
handling of failure is to terminate the process. */
extern int idpriv_drop (void);
/* For approach 3. */
/* Drop the uid and gid privileges of the current process in a way that allows
them to be restored later.
Return 0 if successful, or -1 with errno set upon failure. The recommended
handling of failure is to terminate the process. */
extern int idpriv_temp_drop (void);
/* Restore the uid and gid privileges of the current process.
Return 0 if successful, or -1 with errno set upon failure. The recommended
handling of failure is to not perform the actions that require the escalated
privileges. */
extern int idpriv_temp_restore (void);
#ifdef __cplusplus
}
#endif
#endif /* _IDPRIV_H */

View file

@ -27,7 +27,7 @@
# Specification in the form of a command-line invocation:
# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext mountlist regex setenv strsep timegm unsetenv vasprintf vsnprintf
# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strsep timegm unsetenv vasprintf vsnprintf
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
@ -43,9 +43,11 @@ gl_MODULES([
getloadavg
getopt-gnu
gettext
idpriv-droptemp
mountlist
regex
setenv
strcase
strsep
timegm
unsetenv

View file

@ -28,7 +28,7 @@
# other built files.
# This macro should be invoked from ./configure.in, in the section
# This macro should be invoked from ./configure.ac, in the section
# "Checks for programs", right after AC_PROG_CC, and certainly before
# any checks for libraries, header files, types and library functions.
AC_DEFUN([gl_EARLY],
@ -70,6 +70,7 @@ AC_DEFUN([gl_EARLY],
# Code from module gettext-h:
# Code from module havelib:
# Code from module hostent:
# Code from module idpriv-droptemp:
# Code from module include_next:
# Code from module inet_ntop:
# Code from module intprops:
@ -119,10 +120,12 @@ AC_DEFUN([gl_EARLY],
# Code from module stdint:
# Code from module stdio:
# Code from module stdlib:
# Code from module strcase:
# Code from module streq:
# Code from module strerror:
# Code from module strerror-override:
# Code from module string:
# Code from module strings:
# Code from module strndup:
# Code from module strnlen:
# Code from module strsep:
@ -151,7 +154,7 @@ AC_DEFUN([gl_EARLY],
# Code from module xstrndup:
])
# This macro should be invoked from ./configure.in, in the section
# This macro should be invoked from ./configure.ac, in the section
# "Check for header files, types and library functions".
AC_DEFUN([gl_INIT],
[
@ -256,6 +259,7 @@ AC_DEFUN([gl_INIT],
AC_SUBST([LIBINTL])
AC_SUBST([LTLIBINTL])
gl_HOSTENT
gl_IDPRIV
gl_FUNC_INET_NTOP
if test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1; then
AC_LIBOBJ([inet_ntop])
@ -377,6 +381,15 @@ AC_DEFUN([gl_INIT],
gl_STDINT_H
gl_STDIO_H
gl_STDLIB_H
gl_STRCASE
if test $HAVE_STRCASECMP = 0; then
AC_LIBOBJ([strcasecmp])
gl_PREREQ_STRCASECMP
fi
if test $HAVE_STRNCASECMP = 0; then
AC_LIBOBJ([strncasecmp])
gl_PREREQ_STRNCASECMP
fi
gl_FUNC_STRERROR
if test $REPLACE_STRERROR = 1; then
AC_LIBOBJ([strerror])
@ -390,6 +403,7 @@ AC_DEFUN([gl_INIT],
gl_PREREQ_SYS_H_WINSOCK2
fi
gl_HEADER_STRING_H
gl_HEADER_STRINGS_H
gl_FUNC_STRNDUP
if test $HAVE_STRNDUP = 0 || test $REPLACE_STRNDUP = 1; then
AC_LIBOBJ([strndup])
@ -646,6 +660,8 @@ AC_DEFUN([gl_FILE_LIST], [
lib/glthread/lock.c
lib/glthread/lock.h
lib/glthread/threadlib.c
lib/idpriv-droptemp.c
lib/idpriv.h
lib/inet_ntop.c
lib/intprops.h
lib/itold.c
@ -706,12 +722,15 @@ AC_DEFUN([gl_FILE_LIST], [
lib/stdio.in.h
lib/stdlib.in.h
lib/str-two-way.h
lib/strcasecmp.c
lib/streq.h
lib/strerror-override.c
lib/strerror-override.h
lib/strerror.c
lib/string.in.h
lib/strings.in.h
lib/stripslash.c
lib/strncasecmp.c
lib/strndup.c
lib/strnlen.c
lib/strsep.c
@ -775,6 +794,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/gnulib-common.m4
m4/hostent.m4
m4/iconv.m4
m4/idpriv.m4
m4/include_next.m4
m4/inet_ntop.m4
m4/intdiv0.m4
@ -845,8 +865,10 @@ AC_DEFUN([gl_FILE_LIST], [
m4/stdint_h.m4
m4/stdio_h.m4
m4/stdlib_h.m4
m4/strcase.m4
m4/strerror.m4
m4/string_h.m4
m4/strings_h.m4
m4/strndup.m4
m4/strnlen.m4
m4/strsep.m4

14
gl/m4/idpriv.m4 Normal file
View file

@ -0,0 +1,14 @@
# idpriv.m4 serial 1
dnl Copyright (C) 2009-2013 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_IDPRIV],
[
dnl Persuade glibc <unistd.h> to declare {get,set}res{uid,gid}.
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
AC_CHECK_FUNCS_ONCE([getuid geteuid getresuid getgid getegid getresgid])
AC_CHECK_FUNCS_ONCE([setresuid setreuid seteuid setresgid setregid setegid])
])

45
gl/m4/strcase.m4 Normal file
View file

@ -0,0 +1,45 @@
# strcase.m4 serial 11
dnl Copyright (C) 2002, 2005-2013 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_STRCASE],
[
gl_FUNC_STRCASECMP
gl_FUNC_STRNCASECMP
])
AC_DEFUN([gl_FUNC_STRCASECMP],
[
AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
AC_CHECK_FUNCS([strcasecmp])
if test $ac_cv_func_strcasecmp = no; then
HAVE_STRCASECMP=0
fi
])
AC_DEFUN([gl_FUNC_STRNCASECMP],
[
AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
AC_CHECK_FUNCS([strncasecmp])
if test $ac_cv_func_strncasecmp = yes; then
HAVE_STRNCASECMP=1
else
HAVE_STRNCASECMP=0
fi
AC_CHECK_DECLS([strncasecmp])
if test $ac_cv_have_decl_strncasecmp = no; then
HAVE_DECL_STRNCASECMP=0
fi
])
# Prerequisites of lib/strcasecmp.c.
AC_DEFUN([gl_PREREQ_STRCASECMP], [
:
])
# Prerequisites of lib/strncasecmp.c.
AC_DEFUN([gl_PREREQ_STRNCASECMP], [
:
])

52
gl/m4/strings_h.m4 Normal file
View file

@ -0,0 +1,52 @@
# Configure a replacement for <strings.h>.
# serial 6
# Copyright (C) 2007, 2009-2013 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.
AC_DEFUN([gl_HEADER_STRINGS_H],
[
dnl Use AC_REQUIRE here, so that the default behavior below is expanded
dnl once only, before all statements that occur in other macros.
AC_REQUIRE([gl_HEADER_STRINGS_H_BODY])
])
AC_DEFUN([gl_HEADER_STRINGS_H_BODY],
[
AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
gl_CHECK_NEXT_HEADERS([strings.h])
if test $ac_cv_header_strings_h = yes; then
HAVE_STRINGS_H=1
else
HAVE_STRINGS_H=0
fi
AC_SUBST([HAVE_STRINGS_H])
dnl Check for declarations of anything we want to poison if the
dnl corresponding gnulib module is not in use.
gl_WARN_ON_USE_PREPARE([[
/* Minix 3.1.8 has a bug: <sys/types.h> must be included before
<strings.h>. */
#include <sys/types.h>
#include <strings.h>
]], [ffs strcasecmp strncasecmp])
])
AC_DEFUN([gl_STRINGS_MODULE_INDICATOR],
[
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
gl_MODULE_INDICATOR_SET_VARIABLE([$1])
])
AC_DEFUN([gl_HEADER_STRINGS_H_DEFAULTS],
[
GNULIB_FFS=0; AC_SUBST([GNULIB_FFS])
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_FFS=1; AC_SUBST([HAVE_FFS])
HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP])
HAVE_DECL_STRNCASECMP=1; AC_SUBST([HAVE_DECL_STRNCASECMP])
])

62
gl/strcasecmp.c Normal file
View file

@ -0,0 +1,62 @@
/* Case-insensitive string comparison function.
Copyright (C) 1998-1999, 2005-2007, 2009-2013 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, 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>
/* Specification. */
#include <string.h>
#include <ctype.h>
#include <limits.h>
#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
greater than zero if S1 is lexicographically less than, equal to or greater
than S2.
Note: This function does not work with multibyte strings! */
int
strcasecmp (const char *s1, const char *s2)
{
const unsigned char *p1 = (const unsigned char *) s1;
const unsigned char *p2 = (const unsigned char *) s2;
unsigned char c1, c2;
if (p1 == p2)
return 0;
do
{
c1 = TOLOWER (*p1);
c2 = TOLOWER (*p2);
if (c1 == '\0')
break;
++p1;
++p2;
}
while (c1 == c2);
if (UCHAR_MAX <= INT_MAX)
return c1 - c2;
else
/* On machines where 'char' and 'int' are types of the same size, the
difference of two 'unsigned char' values - including the sign bit -
doesn't fit in an 'int'. */
return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
}

122
gl/strings.in.h Normal file
View file

@ -0,0 +1,122 @@
/* A substitute <strings.h>.
Copyright (C) 2007-2013 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, 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/>. */
#ifndef _@GUARD_PREFIX@_STRINGS_H
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
/* Minix 3.1.8 has a bug: <sys/types.h> must be included before <strings.h>.
But avoid namespace pollution on glibc systems. */
#if defined __minix && !defined __GLIBC__
# include <sys/types.h>
#endif
/* The include_next requires a split double-inclusion guard. */
#if @HAVE_STRINGS_H@
# @INCLUDE_NEXT@ @NEXT_STRINGS_H@
#endif
#ifndef _@GUARD_PREFIX@_STRINGS_H
#define _@GUARD_PREFIX@_STRINGS_H
#if ! @HAVE_DECL_STRNCASECMP@
/* Get size_t. */
# include <stddef.h>
#endif
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
/* The definition of _GL_WARN_ON_USE is copied here. */
#ifdef __cplusplus
extern "C" {
#endif
/* Find the index of the least-significant set bit. */
#if @GNULIB_FFS@
# if !@HAVE_FFS@
_GL_FUNCDECL_SYS (ffs, int, (int i));
# endif
_GL_CXXALIAS_SYS (ffs, int, (int i));
_GL_CXXALIASWARN (ffs);
#elif defined GNULIB_POSIXCHECK
# undef ffs
# if HAVE_RAW_DECL_FFS
_GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module");
# endif
#endif
/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
greater than zero if S1 is lexicographically less than, equal to or greater
than S2.
Note: This function does not work in multibyte locales. */
#if ! @HAVE_STRCASECMP@
extern int strcasecmp (char const *s1, char const *s2)
_GL_ARG_NONNULL ((1, 2));
#endif
#if defined GNULIB_POSIXCHECK
/* strcasecmp() does not work with multibyte strings:
POSIX says that it operates on "strings", and "string" in POSIX is defined
as a sequence of bytes, not of characters. */
# undef strcasecmp
# if HAVE_RAW_DECL_STRCASECMP
_GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character "
"strings in multibyte locales - "
"use mbscasecmp if you care about "
"internationalization, or use c_strcasecmp , "
"gnulib module c-strcase) if you want a locale "
"independent function");
# endif
#endif
/* Compare no more than N bytes of strings S1 and S2, ignoring case,
returning less than, equal to or greater than zero if S1 is
lexicographically less than, equal to or greater than S2.
Note: This function cannot work correctly in multibyte locales. */
#if ! @HAVE_DECL_STRNCASECMP@
extern int strncasecmp (char const *s1, char const *s2, size_t n)
_GL_ARG_NONNULL ((1, 2));
#endif
#if defined GNULIB_POSIXCHECK
/* strncasecmp() does not work with multibyte strings:
POSIX says that it operates on "strings", and "string" in POSIX is defined
as a sequence of bytes, not of characters. */
# undef strncasecmp
# if HAVE_RAW_DECL_STRNCASECMP
_GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character "
"strings in multibyte locales - "
"use mbsncasecmp or mbspcasecmp if you care about "
"internationalization, or use c_strncasecmp , "
"gnulib module c-strcase) if you want a locale "
"independent function");
# endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* _@GUARD_PREFIX@_STRING_H */
#endif /* _@GUARD_PREFIX@_STRING_H */

62
gl/strncasecmp.c Normal file
View file

@ -0,0 +1,62 @@
/* strncasecmp.c -- case insensitive string comparator
Copyright (C) 1998-1999, 2005-2007, 2009-2013 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, 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>
/* Specification. */
#include <string.h>
#include <ctype.h>
#include <limits.h>
#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
/* Compare no more than N bytes of strings S1 and S2, ignoring case,
returning less than, equal to or greater than zero if S1 is
lexicographically less than, equal to or greater than S2.
Note: This function cannot work correctly in multibyte locales. */
int
strncasecmp (const char *s1, const char *s2, size_t n)
{
register const unsigned char *p1 = (const unsigned char *) s1;
register const unsigned char *p2 = (const unsigned char *) s2;
unsigned char c1, c2;
if (p1 == p2 || n == 0)
return 0;
do
{
c1 = TOLOWER (*p1);
c2 = TOLOWER (*p2);
if (--n == 0 || c1 == '\0')
break;
++p1;
++p2;
}
while (c1 == c2);
if (UCHAR_MAX <= INT_MAX)
return c1 - c2;
else
/* On machines where 'char' and 'int' are types of the same size, the
difference of two 'unsigned char' values - including the sign bit -
doesn't fit in an 'int'. */
return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
}